Sunday, June 12, 2011

Using Code On a PC to Interact with the Arduino

Writing firmware to operate a microcontroller such as the Arduino can provide the user with an array of power at his disposal, but the processing power and further interaction is limited due to the nature of the microcontroller itself (its a MICROcontroller aka not an Intel processor).  With this in mind, I was interested in interacting with the Arduino on my PC.  At first I thought I would have to do this in C using Visual Studio and the Windows library (to talk to the COMM PORTS); however, I found another open source compiler from the creators of the Arduino sketchbook called Processing: 

"Processing is an open source programming language and environment for people who want to create images, animations, and interactions. Initially developed to serve as a software sketchbook and to teach fundamentals of computer programming within a visual context, Processing also has evolved into a tool for generating finished professional work. Today, there are tens of thousands of students, artists, designers, researchers, and hobbyists who use Processing for learning, prototyping, and production" 
-www.processing.org



Here's the simple setup for downloading Processing and setting it up for Arduino interaction:

  1. Download the processing zip file from http://processing.org/download/
  2. Extract this file
  3. Download the Arduino Processing library at: http://arduino.cc/playground/uploads/Nilseuropa/processing-arduinomega.zip
  4. Extract this file
  5. Create a folder in your Processing folder called "libraries"; the Processing folder is most likely loaded in your My Documents (not to be confused with the processing zip file that you just downloaded) 
  6. Copy the Arduino folder from the extracted file into the Processing folder
  7. Open up the Processing sketchbook, click Sketch->Import Library and you should see an Arduino library at the bottom of the list
  8. You are good to go! Just include the Arduino library and the Serial library anytime you use Processing to interact with the Arduino. Examples can be found on the Processing website and on the Arduino website (www.arduino.cc)
For my next project I am going to use an infrared sensor to detect motion and use the Arduino and Bluetooth to wirelessly report whenever the motion detector goes off using the Processing sketchbook.


No comments:

Post a Comment