Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created February 19, 2020 00:18
Show Gist options
  • Save parzibyte/10202e7b87fe92a754e340babaf9e1f5 to your computer and use it in GitHub Desktop.
Save parzibyte/10202e7b87fe92a754e340babaf9e1f5 to your computer and use it in GitHub Desktop.
/*
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