Last of updates to arduino code

Organized code into functions, and changed the way config changes are
sent/executed on the arduino.