14.9 - Compile and Upload Arduino Sketches Programmatically

With this short Jython script, an Arduino service is created and a Arduino sketch is compiled then uploaded to the microcontroller.  In this case the sketch is MRLComm which allows communication between MRL and Arduio, but other sketches could be loaded too, depending on the state of the Borg :)


from org.myrobotlab.service import Arduino

# create an Arduino service
arduino = runtime.createAndStart('arduino','Arduino')

# set board's serial port

#set the serial parameters of the connection
arduino.setSerialPortParams (57600, 8, 1, 0)


arduino.pinMode(44, Arduino.OUTPUT)
arduino.digitalWrite(44, Arduino.HIGH)