Changes

Jump to: navigation, search

Week 4 Lab

252 bytes added, 15:35, 21 April 2009
The other way around: Driving a Computer Program with Data from the Arduino
*Change the <code>Integer.parseInt(buff);</code> statements to say <code>rval = Integer.parseInt(buff)/4;</code>. This relates to the issue last week with the <code>analogRead()</code> and <code>analogWrite()</code>: our Arduino is transmitting a 10bit (0-1023) value captured from the <code>analogRead()</code>, but the <code>background(rval, gval, bval);</code> command in Processing wants 8bit (0-255) values for Red, Green, and Blue. Thus, we need to divide the 10 bit values by 4.
[[Image:Arduino_color_mixer.png|300px]]
* Run this program (same as on the Arduino, click the little "Play" button at the upper left). A NOTE: Hold down the reset button on your Arduino while you start the Processing applet. Release the button once the new window has appeared. If you do not, the Processing applet will start reading mid-data stream, which will confuse it and crash. You should appear see something like the one window below:
[[Image:Color_mix.png]]
 
* You should be able to change the color of the on-screen square by dialing the knobs back and forth.

Navigation menu