Created
September 23, 2013 19:18
-
-
Save blackymetal/6675490 to your computer and use it in GitHub Desktop.
Blink LED from serial
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| int incomingByte = 0; // para el byte leido | |
| int biggreen = 7; | |
| int red = 8; | |
| int green = 9; | |
| void setup() { | |
| // put your setup code here, to run once: | |
| Serial.begin(9600); | |
| pinMode(red, OUTPUT); | |
| pinMode(green, OUTPUT); | |
| pinMode(biggreen, OUTPUT); | |
| } | |
| void loop() { | |
| // put your main code here, to run repeatedly: | |
| // envia datos solamente cuando recibe datos | |
| if (Serial.available() > 0) { | |
| // lee el byte entrante: | |
| incomingByte = Serial.read(); | |
| // dice lo que ha recibido: | |
| Serial.print("He recibido: "); | |
| Serial.println(incomingByte, DEC); | |
| if(incomingByte == 55) { | |
| digitalWrite(biggreen, HIGH); | |
| } | |
| if(incomingByte == 56) { | |
| digitalWrite(red, HIGH); | |
| } | |
| if(incomingByte == 57) { | |
| digitalWrite(green, HIGH); | |
| } | |
| delay(100); | |
| digitalWrite(biggreen, LOW); | |
| digitalWrite(red, LOW); | |
| digitalWrite(green, LOW); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment