Skip to content

Instantly share code, notes, and snippets.

@chaeplin
Last active January 29, 2016 14:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chaeplin/d5b0e870335a24aa000d to your computer and use it in GitHub Desktop.
Save chaeplin/d5b0e870335a24aa000d to your computer and use it in GitHub Desktop.
callback.ino
void callback(char* topic, byte* payload, unsigned int length) {
String receivedtopic = topic;
String receivedpayload ;
for (int i = 0; i < length; i++) {
receivedpayload += (char)payload[i];
}
Serial.print(receivedtopic);
Serial.print(" => ");
Serial.println(receivedpayload);
if ( receivedtopic == "inside") {
lcd.setBacklight(HIGH);
lcd.display();
lcd.home (); // set cursor to 0,0
lcd.print ("Inside is: ");
lcd.setCursor (13, 0);
lcd.print(receivedpayload);
}
if ( receivedtopic == "outside") {
lcd.setCursor (0, 1);
lcd.print ("Outside is: ");
lcd.setCursor (13, 1);
lcd.print(receivedpayload);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment