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
/* | |
No tengo idea, pero parece que está invertido y al escribir un HIGH | |
se apaga | |
Relaciondo: https://github.com/nodemcu/nodemcu-devkit-v1.0/issues/16 | |
*/ | |
void apagarLed() | |
{ | |
digitalWrite(PIN_LED, HIGH); | |
} | |
void encenderLed() | |
{ | |
digitalWrite(PIN_LED, LOW); | |
} | |
// La función que será llamada cuando se reciba un | |
// mensaje en el tópico al que nos vamos a suscribir | |
void callback(char *topico, byte *cargaUtil, unsigned int longitudDeDatos) | |
{ | |
if (longitudDeDatos <= 0) | |
return; | |
char primerCaracter = (char)cargaUtil[0]; | |
if (primerCaracter == '0') | |
apagarLed(); | |
else if (primerCaracter == '1') | |
encenderLed(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment