Crowpanel 4.3" Display
I have an Arduino project and I am passing the following:
int backlightPin = 2;
if (strcmp(topic, "elecrow/backlight/state") == 0) {
if (message == "on") {
digitalWrite(backlightPin, HIGH); // Turns on backlight
} else {
digitalWrite(backlightPin, LOW); // Turns off backlight
}
Serial.println("Backlight: " + message);
}
Looking at Serial Monitor I see
Backlight: on
Backlight: off
As proof that it is passing this section ok.
Any advise would be helpfull.
Tagged:
Comments
Added PinMode to Setup, and it now works
define BACKLIGHT_PIN 2 // Set The backlight Pin
if (strcmp(topic, "elecrow/backlight/state") == 0) {
if (message == "on") {
digitalWrite(BACKLIGHT_PIN, HIGH); // Turns on backlight
} else {
digitalWrite(BACKLIGHT_PIN, LOW); // Turns off backlight
}
Serial.println("Backlight: " + message);
}
void setup() {
//Initialise backlight pin, this will turn off the display, so make sure you turn it on
pinMode(BACKLIGHT_PIN, OUTPUT);
delay(5);
digitalWrite(BACKLIGHT_PIN, HIGH); // Turns on backlight
}