Changes

Week 4 Lab

2 bytes removed, 04:49, 21 April 2009
controlling from a Processing app
* In Processing, open a new sketch, and copy this code into it. Save this sketch as "arduino_test" or something like that. It should look like this:
[[Image:Arduino_serialtest_processing.png|300px]]
** Try running this sketch. When you do, it may give you an error about "COM1" or something of that sort. You need to tell the program what serial port your arduino is connected to. When the program runs, you will see a list of Serial ports, you can see mine in the picture above. On my comnputer, I see that my serial port is the "tty.usbserial-A900acnt", which is listed as device number 2 ([2]), so I go back into the processing code and change the line that says <code>port = new Serial</code>... to read <code>port = new Serial(this, Serial.list()[2], 9600);</code>** Now if I run the sketch again, I know that it will be properly communicating with the Arduino. You will need to modify that line to reflect whichever serial port your arduino is connected to.
* Upload the original (unmodified) Dimmer code to your arduino in the arduino software. Your processor should now be running that code... waiting for input!
* Run your newly created arduino_test sketch in processing. You will see a small graphic window (like the one below), as you drag your mouse forwards and backwards across that window, your motor should speed up and slow down. Allright!! Now you have a simple graphical interface!