Arduino, Firmata and XMLRPC with AppleScript

As many things in life its only when we try something we know if it could work or not. What if I could use XMLRPC call and talk to Firmata. Lets do a example of the blink sketch there I could change parameters from AppleScript and not on the main code itself.

  • Firmata is a way to talk to Arduino.

We need pyFirmata pip install pyFirmata
We also need to upload from Arduino IDE StandardFirmata to the Arduino board.
We also need 1 LED, 1 resistor to build the circuit on the breadboard.

set {digitalPin, sleepTime, repeatCount} to {13, 2, 3}
its methodName:"arduino_blink" params:{digitalPin, sleepTime, repeatCount}
on methodName:methodName params:params
	tell application "http://localhost:7080"
		call xmlrpc {method name:methodName, parameters:params}
	end tell
end methodName:params:

The XMLRPC function need this to be included in XMLRPC Twisted server.
import pyfirmata
import time

You also need to make sure this line: pyfirmata.Arduino(‘/dev/cu.usbmodem2101’)
match your configuration. It could be that you use other USB port and I did.

def xmlrpc_arduino_blink(self, *args):
    board = pyfirmata.Arduino('/dev/cu.usbmodem2101')
    dp = args[0]
    ts = args[1]
    rc = args[2]
    for n in range(1, rc + 1):
        if(n % rc == 0):
    return "LED have been blinked " + str(rc) + " times"