In this example we control an LED (red one in the picture) with a poti - everything via some logic in a VVVV patch.
Very short spoken we do: poti > arduino > vvvv (calculate: is LED on/off?) > arduino > control LED
That means we have to do:
Make sure to upload this code to the arduino board:
/* send/recieve data to/from vvvv
* -----------
*
* poti --> arduino --> vvvv --> arduino --> control LED
* 17-01-2006
* copyleft 2006 benedikt gross
*
* Last edit Westbam 20-08-2009, for new Serial. code.
*
*/
int potPin = 5; // select the input pin for the potentiometer
int ledPin = 13; // select the pin for the LED
int val,serialGet = 0; // variable to store the value coming from the sensor/serial port (from vvvv)
int delaytime = 1; // delay time for the main loop
void setup() {
pinMode(ledPin, OUTPUT); // declare the ledPin as an OUTPUT
Serial.begin(9600); // use the serial port to send/recieve values to/from the computer
}
void loop() {
val = analogRead(potPin); // read the value from the potentiometer
Serial.print (val); // print the value to the serial port
//linebreak
Serial.write(10);
Serial.write(13);
// read the serial port
serialGet = Serial.read();
// if the input is '-1' then there is no data
// at the input, otherwise store it
if (serialGet != -1) {
val = serialGet;
}
// if the stored value is 'H' turn the LED on
// if the stored value is 'L' turn the LED off
if (val == 'H') {
digitalWrite(ledPin, HIGH);
}
else if (val == 'L') {
digitalWrite(ledPin, LOW);
}
delay(delaytime);
}
See how to connect the poti, middle pin of the poti to analog in 5, the outer pins to GND and 5v. If you reverse, the graph in the patch also reverses.

And here the patch, don't forget to set the correct com in the RS232 node.

anonymous user login
16:56, 10.09.10
16:53, 10.09.10
12:41, 10.09.10
22:12, 09.09.10
22:12, 09.09.10
21:21, 09.09.10
17:58, 09.09.10
14:51, 09.09.10