Created
January 21, 2018 01:21
-
-
Save esmarr58/2567d7fe5b78ad2d945ebb9a6afce7ef to your computer and use it in GitHub Desktop.
This file contains 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 ledPin = 12; | |
int state = 0; | |
void setup(){ | |
pinMode(ledPin, OUTPUT); | |
digitalWrite(ledPin, LOW); | |
Serial.begin(9600); | |
} | |
void loop(){ | |
//Si el modulo "A" manda un dato,guardarlo en estado | |
if(Serial.available() > 0) { | |
state = Serial.read(); | |
} //Esta parte del código es para sólo 1 carácter o unidad | |
//Si el estado es 0, ese sería apagado "OFF" | |
if (state == '0'){ | |
digitalWrite(ledPin, LOW); | |
Serial.println("LED: off"); | |
} | |
//Si el estado es 1, ese sería encendido | |
else if(state == '1') { | |
digitalWrite(ledPin, HIGH); | |
Serial.println("LED: on"); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment