I have bought a Red Serial LCD from sparkfun, ( http://www.sparkfun.com/commerce/product_info.php?products_id=9394 ) and am trying to adjust the brightness with arduino as i need to make it visible behind a translucent black plastic sheet. At the moment the Red simply doesnt shine through, i was wondering if anyone has changed the brightness and how it compares to a basic red LED, and also what code i need to be using to adjust it? I have tried before but it didnt seem to dim or brighten the backlight.
I was messing around with the brightness of my SparkFun 2.5 Serial LCD today and came up with the following, using a potentiometer connected to A0 [Value 0 - 1023] to control the LCD brightness [Value 128 - 157]. You can see the simple fitting parameter in the math section of my code.
/*
Try to control the serial LCD brightness with a potentiometer
*/
int sensorPin = 0;
int sensorValue = 0;
int brightnessIndex = 128;
int brightnessPrev = 128;
void setup()
{
Serial.begin(9600);
}
// Starts the cursor at the beginning of the first line (convienence method for goTo(0))
void selectLineOne() { //puts the cursor at line 0 char 0.
serCommand(); //command flag
Serial.print(128, BYTE); //position
}
// Starts the cursor at the beginning of the second line (convienence method for goTo(16))
void selectLineTwo() { //puts the cursor at line 0 char 0.
serCommand(); //command flag
Serial.print(192, BYTE); //position
}
// Resets the display, undoing any scroll and removing all text
void clearLCD() {
serCommand();
Serial.print(0x01, BYTE);
}
// Turns the backlight on
void backlightOn() {
serLcd();
Serial.print(157, BYTE);
//128 off
//140 40%
//150 73%
//157 Fully on
}
// Turns the backlight off
void backlightOff() {
serLcd();
Serial.print(128, BYTE);
}
// Initiates a function command to the display
void serCommand() {
Serial.print(0xFE, BYTE);
}
void serLcd() {
Serial.print(0x7C, BYTE);
}
void loop()
{
Serial.print("PotVal = ");
sensorValue = analogRead(sensorPin);
clearLCD();
selectLineOne();
Serial.print("PotVal = ");
Serial.print(sensorValue);
// Match the potentiometer limits with the LCD brightness value limits
brightnessIndex = round(157 - 29 * (1023 - sensorValue) / 1023);
selectLineTwo();
Serial.print("Bright = ");
Serial.print(brightnessIndex);
// Only send brightness adjustments when there has been a change (reduces flicker)
if ( brightnessIndex != brightnessPrev )
{
serLcd();
Serial.print(brightnessIndex, BYTE);
brightnessPrev = brightnessIndex;
}
// Play with this delay according to your needs
delay(200);
}
Hi, thanks for that code, however, although helpful it didnt seem to change brightness? is the change substantial or minimal? i have taken some photos to show the difference, if there is any? i cant seem to see any.
LCD at 128 brightness
LCD at 157 brightness
Can anyone see a difference? is that how it is suppose to be, a minimal change?
Red is a low wavelength. A red filter would be better as it would not let any light through apart from the red light from the display. I presume that you want a filter so that you cannot see the display when it is off.
A dark magenta filter should work well.
It is indeed to stop it being seen behind when off, however i am very far on with this project and a front face, of which the LCD will be behind, has already been made in black and due to time will be unable to make a different coloured face.
Do you know if the white might be better at showing through the black or do you think it will be much the same issue?
Hmm, I would have thought you will have issues whatever colour you use.
White would probably be better as there is more of the spectrum of light to pass through and it is probably 'brighter' for that reason.
Here's what it should look like... It seems like your LCD isn't registering the brightness commands, because 128 brightness should = OFF, and 157 is max brightness.
Ahh yeah, that does seem to suggest there is something up with my LCD :S. That is a lot lot brighter at 157 aswell, i think? do you agree?
Hmmm, could it be the actuall hardware that isnt too good, i think this has been the problem all along as i have tried to set it to 128 before and it has never worked.
I have connected the LCD into the tx pin on the arduino, thats right yeah? ...
I didn't have a connector so I just used some pins, and I'm getting ground from another part of the board just to keep it safely away from Vcc. Good luck!
I tried to use that pin one on the side of the LCD rather than the JST 3-pin and it didnt seem to work, i wasnt getting a readout on the screen.
This mystery seems so odd. Has anyone else had this experience? Is it something with the way it is connected up? Or is it more likely something to do with my board?