Using Pyaler is smooth and fast. You just need to install the package the way you prefer, adapt the configuration file to fit your arduino code and match the computer's serial configuration and then execute Pyaler or make it integrated with Apache.

Here a 5 minutes tutorial to instanciate Pyaler:

Instanciate play.pyaler.org example

Pyaler's configuration's file match every serial interface connected to an arduino with names, and it match actions with names. e.g. here is the configuration file for the demo given on this site :

arduinos:
    lolshield: /dev/ttyUSB0

read_actions:
    demo: HACK ME ON http://play.pyaler.org !

write_actions:
    write:

Here is declared an arduino called 'lolshield' (name of the shield designed by Jimmie P. Rodgers), connected to the computer's serial port (here, it is ttyUSB0, a linux interface name)

Then, we define actions. The dictionary 'read_actions' is used to define actions on the arduino launched by HTTP GET queries ; the dictionary 'write_actions' does the same with HTTP POST queries, but it needs a POST field called value containing the value you want to feed the arduino with.

In the above example, when one send a POST request with 'value="foobar"' on http://my.host/lolshield/write, the string 'foobar' is written on the serial line of the arduino, that will display the text. The code ran by the arduino in our demo is available on github which will have parts integrated to the code given with the lolshield.

Control light emitting diods

The first demo we built with pyaler was to control a RGB led, the same way as done by yaler.org's demo. Here is the configuration we used for that purpose :

arduinos:
    leds: /dev/ttyUSB0

read_actions:
    red: 1
    blue: 2
    green: 3
    no_red: 4
    no_green: 6
    no_blue: 5
    none: 0


write_actions:
Here, we use only HTTP GET requests that will send the matching value to the arduino. So when you query 'http://my.host/leds/red', the string '1' is written on serial line, and the Arduino, once flashed with the program below, will set to HIGH the pin that lights the led in red.

int incomingByte = 0;
int ledPinRed = 13;
int ledPinGND = 12;
int ledPinGreen = 11;
int ledPinBlue = 10;

void setup() {
      Serial.begin(9600);
      pinMode(ledPinRed, OUTPUT);
      pinMode(ledPinGND, OUTPUT);
      pinMode(ledPinGreen, OUTPUT);
      pinMode(ledPinBlue, OUTPUT);
}

void loop() {
      if (Serial.available() > 0) {
        digitalWrite(ledPinGND, LOW);
        
        incomingByte = Serial.read();
        if (incomingByte == 49) {
            digitalWrite(ledPinRed, HIGH);
            Serial.println('Red LED turned ON');
        }
        if (incomingByte == 50) {
            digitalWrite(ledPinGreen, HIGH);
            Serial.println('Green LED turned ON');
        }
        if (incomingByte == 51) {
            digitalWrite(ledPinBlue, HIGH);
            Serial.println('Blue LED turned ON');
        }
        if (incomingByte == 52) {
            digitalWrite(ledPinRed, LOW);
            Serial.println('Red LED turned ON');
        }
        if (incomingByte == 53) {
            digitalWrite(ledPinGreen, LOW);
            Serial.println('Green LED turned ON');
        }
        if (incomingByte == 54) {
            digitalWrite(ledPinBlue, LOW);
            Serial.println('Blue LED turned ON');
        }
        if (incomingByte == 48) {   
            digitalWrite(ledPinRed, LOW);
            digitalWrite(ledPinGreen, LOW);
            digitalWrite(ledPinBlue, LOW);
            Serial.println('LEDs turned OFF');
        }
    }
}