backlight LED works backwards?
Hello,
I'm testing the arduino, trying to read input CH2, and consequently turn on backlight (pin 13), turn on LED attached to CH3, and update LCD.
However the backlight seem to go on when CH3 is off and vice versa.
here's the code:
#include <UC1701.h>
#include <Wire.h>
#include <Indio.h>
static UC1701 lcd;
void setup() {
lcd.begin();
Indio.digitalMode(2,INPUT); // Set CH2 as an input
Indio.digitalMode(3,OUTPUT); // Set CH3 as an input
pinMode(13,OUTPUT); // 13 is the backlight
lcd.setCursor(0, 1);
lcd.print("channel 2");
}
void loop() {
// check if the pushbutton is pressed.
// if it is, the CH2 button is HIGH:
if (Indio.digitalRead(2) == HIGH) {
// turn LED on:
digitalWrite(13, HIGH);
Indio.digitalWrite(3, HIGH);
// and write high
lcd.setCursor(64, 1);
lcd.print("high");
}
else {
// turn LED off:
digitalWrite(13, HIGH);
Indio.digitalWrite(3, HIGH);
lcd.setCursor(64, 1);
lcd.print("low ");
}
}
am I doing something wrong?
Yeah, i made a mistake when copying the sketch here, actual code said Low on both LEDs in the "else" clause.
Thanks for the reply!
Hello Alessandro, Yes that is correct, the backlight works inverse because it is switched by a PNP transistor. Best Regards, Loic
Your answer
Please try to give a substantial answer. If you wanted to comment on the question or answer, just use the commenting tool. Please remember that you can always revise your answers - no need to answer the same question twice. Also, please don't forget to vote - it really helps to select the best questions and answers!
Keep Informed
About This Forum
This community is for professionals and enthusiasts of our products and services.
Read GuidelinesQuestion tools
Stats
Asked: 6/16/15, 11:47 PM |
Seen: 3498 times |
Last updated: 6/17/15, 12:09 PM |
I see in your code that you write "HIGH" to D13 twice, basically keeping the backlight off. So to make it work you need to change it to "LOW" in the first "if" routine.