» fr.arduino03
This site relies heavily on Javascript. You should enable it if you want the full experience. Learn more.

fr.arduino03

English

!02 Envoyer et recevoir des données depuis/vers Arduino
Dans cet exemple nous allons contrôler une LED (rouge sur l'image) avec un potentiomètre - et tout ça avec un peu de logique dans un patch vvvv.
Pour schématiser: potar > vvvv (calcule: LED allumée ou éteinte?) > Arduino --> contrôle de LED.

Ca signifie que nous devons:

  • connecter un potentiomètre à la carte. Fil central du potar à l'entrée analogique 5, fils gauche et droite sur GND et 5V. (les broches analogiques d'entrée peuvent "lire" une tension entre 0 et 5V avec une résolution de 10bit = 0-1024)
  • envoyer la valeur à vvvv
  • calculer on/off?
    • si la valeur est en-dessous de 512 = LED off
    • autrement = LED on
  • renvoyer les données à la carte
  • en fonction des données de vvvv: basculer la LED sur la broche 13 on/off

Assurez-vous de charger ce code dans la carte Arduino:

/* send/recieve data to/from vvvvv

  • ---

*

  • poti > arduino > vvvv > arduino > control LED
  • 17-01-2006
  • copyleft 2006 benedikt gross
  • <http://www.looksgood.de>

*/

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
  beginSerial(9600);        // use the serial port to send/recieve values to/from the computer

}

void loop() {

  val = analogRead(potPin);    // read the value from the potentiometer
  printInteger(val);           // print the value to the serial port
  //linebreak
  serialWrite(10); 
  serialWrite(13);  
  // read the serial port
  serialGet = serialRead();
  // 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); 

}

Regardez comment connecter le potentiomètre:

Et le patch se trouve ici:

Sommaire

anonymous user login

Shoutbox

~6min ago

tekcor: hm how do i create a single mesh from primitive geometrys and spreaded transform?

~4h ago

graphicuserinterface: @zepi:skynet is becoming self aware

~20h ago

flateric: Thanks devvvvs, I owe you a few bananas next time we meet :)

~2d ago

kiilo: @rexmtl im going to foulab later ...

~2d ago

kiilo: @wxmtl YES im in Montreal please contact me in the IRC chat or skype

~2d ago

rexmtl: I need help learning VVVV. Anyone in Montreal willing to help> I'm desperate