daily pastebin goal
7%
SHARE
TWEET

Untitled

a guest Oct 30th, 2016 25 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. char valor;
  2. int ledVerde = 8;
  3. int ledVermelho = 9;
  4.  
  5.  
  6. void setup() {
  7.   // Definir LEDs como OUTPUTs
  8.   pinMode(ledVerde, OUTPUT);
  9.   pinMode(ledVermel, OUTPUT);
  10.   // Iniciar comunicacao serie
  11.   Serial.begin(9600);
  12. }
  13.  
  14. void loop() {
  15.   if (Serial.available())
  16.   {
  17.     // Guardar valor lido e recebido do Processing
  18.     valor = Serial.read();
  19.   }
  20.  
  21.  
  22.   // Se o valor recebido for igual a 1, acender o LED verde
  23.   if (valor == '1')
  24.   {
  25.     digitalWrite(ledVerde, HIGH);
  26.   }
  27.  
  28.   // Se o valor recebido for igual a 2, desligar o LED verde
  29.   else if (valor == '2')
  30.   {
  31.     digitalWrite(ledVerde, LOW);
  32.   }
  33.  
  34.   // Se o valor recebido for igual a 3, acender o LED vermelho
  35.   else if (valor == '3')
  36.   {
  37.     digitalWrite(ledVermel, HIGH);
  38.   }
  39.  
  40.   // Se o valor recebido for igual a 4, desligar o LED vermelho
  41.   else if (valor == '4')
  42.   {
  43.     digitalWrite(ledVermel, LOW);
  44.   }
  45.   }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top