INTERACTION DESIGN STUDIO
Alis Blog Processing and EEG

PROCESSING, ARDUINO AND EEG PART 1

TIME TO CONNECT




In the following sketches, we are going to focus on the connection between Processing and Arduino. What we are trying to achieve is to control external components (first LEDs and then DC motors) according to the data derived from the EEG headset. As described in Arduino Playground, the initial step is to make Arduino and Processing talk to each other by using the Firmata found under the Processing Libraries. Unzip the library and copy the “Arduino” folder into the “libraries” sub-folder of the Processing Sketchbook. (For Processing 3 users, go to Sketch>Import Library>Add Library and in the panel Install Firmata.)

Processing and Arduino through Firmata Sketch 04a

Run Arduino, open the Examples > Firmata > StandardFirmata sketch and upload it to the Arduino board. (If you face a problem while uploading the sketch and see an error as ‘avrdude: stk500_recv(): programmer is not responding’, you may want to check out THIS fix to overcome the problem). Then configure Processing for serial connection. To do this, browse through Processing > Examples > Contributed Libraries > Arduino > arduino_output and run the sketch. Edit the marked part of the code to select the serial port used by Arduino.

Processing and Arduino through Firmata Sketch 04b

Specifically, change the [0] in this line:

arduino = new Arduino(this, Arduino.list()[0], 57600);

 

with the correct item in the array. Select the number corresponding to the serial port in your Arduino environment found under Tools > Serial Port. The first item is enumerated as [0] so our item would be [2] in the list.

arduino = new Arduino(this, Arduino.list()[2], 57600);

 

After modifying this particular line, run the sketch again and click on the first empty square in the running sketch which corresponds to Pin 13. In the Arduino board, you will see the Led that corresponds to Pin 13 light up. Great, we are done :) Our Arduino and Processing Sketch are talking to each other.