Advertisement
adnocarvalho

CONTROLANDO_LED_PELA_SERIAL-_1_LIGA_E_2_DESL

Jan 5th, 2016
3,269
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. int led = 9;
  2. int numero = -1;
  3.  
  4. void setup(){
  5.  pinMode(led,OUTPUT);
  6.  Serial.begin(9600);
  7. }
  8.  
  9. void loop(){
  10.      if (Serial.available() > 0){
  11.          numero = Serial.read();  
  12.         }
  13.      
  14.      if (numero == 49){
  15.       digitalWrite(led,HIGH);
  16.       Serial.println("Ligado");
  17.       delay(200);    
  18.         }
  19.    else
  20.        if (numero == 48){
  21.       digitalWrite(led,LOW);
  22.       Serial.println("Desligado");  
  23.       delay(200);  
  24.         }  
  25.    
  26.     numero = -1;
  27.              
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement