Arduino – Processing

Using Processing to program the Arduino. This is a short tutorial for absolute beginners.

Arduino Duemilanove

Download and install the latest version of the Arduino software from:
http://www.arduino.cc/en/Main/Software

Download the Processing – Arduino library from:
http://playground.arduino.cc/uploads/Interfacing/processing2-arduino.zip

Connect the Arduino with the PC using an USB cable.

Start arduino.exe and open file > examples > Firmata > StandardFirmata

Standard Firmata

Make sure it’s using the right Arduino board: Tools > Board
If the wrong board is selected you will get an ‘avrdude: stk500_getsync()’ error!

CHECK WHICH COM PORT TO USE, IN THE DEVICE MANAGER:

Device Manager

In the Arduino app select the COM-port that says ‘USB Serial Port‘ (Tools > Serial Port)
(in the picture above it’s COM-port 6)

Verify the Arduino sketch (CTRL-R).
Upload the sketch to the board (CTRL-U).
Connect a LED between PIN 13 and GND (short leg of the LED goes to ground!).

Open Processing and create the following sketch:

import processing.serial.*;
import cc.arduino.*;

Arduino arduino;

void setup()
{
  println(Arduino.list());
  // Find your COM-PORT in the list and
  // replace [2] with the index of your port
  arduino = new Arduino(this, Arduino.list()[2], 57600);
  arduino.pinMode(13, Arduino.OUTPUT);
}

void draw()
{
  arduino.digitalWrite(13, Arduino.HIGH);
  delay(1000);
  arduino.digitalWrite(13, Arduino.LOW);
  delay(1000);
}

Run the sketch and the LED will be blinking every second!

Resources:
http://playground.arduino.cc/Interfacing/Processing