I'm looking for a method to control the backlight of an LCD display which will be mounted in a car such that it is dimmed when the headlights are turned on.
My current thinking is to use a 555 timer in astable configuration to drive the LED via PWM. I could then, via a voltage divider, manipulate the PWM using the control pin on the 555. That is, when the headlights are on, the control pin would be fed a voltage from the wire that energises the headlight relay via a resistor divider.
Does this seem like a reasonable plan, or is there a better solution available? I don't want to control this directly via the Arduino as I am concerned I'll be running towards the program space limit as it is, and don't want to go to a mega if I can avoid it.
You have to specify the type of LCD for anyone to answer your question. I2C LCDs have a trimpot built into the pcb. 4-bit parallel LCDs have a contrast pin where you connect a user added pot.
You need to identify YOUR pot. Then we can proceed from there. Post a vendor link for your lcd.
Sorry, it's just a generic hitachi driver lcd which uses an led as a back light. It's not mounted to a pre fabricated shield or anything of that nature.
Basically, I just need a method to control the brightness of an led (which, in this case, happens to be built into an lcd), to two preset levels. The less bright level needs to be activated via the application of a voltage from an external source.
raschemmel:
read the question and answer with one of the two types as identified or post aschematic
If it's 4-bit, say so
I did read your question, and I thought I had provided information relevant to the problem I want to solve.
At any rate, it is a 4 bit paralell LCD. I do understand the function and purpose of the contrast pin, but I do not want to manipulate the contrast. What I want to do is control the intensity of the led that is used as a backlight for the display. This has its own seperate a and k pins, seperate to the contrast and data pins.
For the purposes of my question, it doesn't really matter that the led is installed in an LCD. I basically just want to be able to set an led to two levels of brightness.
Level one is set when an external voltage is at ground
Level two is set when that external voltage is something other than ground.
The external voltage will come from the circuit that energises the headlight relay coil in a car, thus, when the headlights are turned on, the intensity of the led is reduced.
Most generic 4-bit lcds are used with an 80 ohm to 100 ohm in series with the +5V because the backlight led runs on 4.2V. You can simply use a 2n2222 transistor with a 470 ohm base resistor, emitter to GND, and an 80 ohm resistor in series with the led Anode pin and the cathode connected to ground so the backlight current is sinked by the transistor and PWM the base resistor with a PWM pin. You don't need a 555. You can just as easily do this with an 8-pin ATtiny85 if you know how to use those. If you don't , then there is a learning curve because unless you are a professional electronics tech, the instructions on how to use it might be too much for you. The ATtiny85 needs to be programmed with an UNO, you need use ArduinoISP, you need to install the tiny cores. etc etc. Detecting when the headlights are on is straightforward by why would you want the backlight DIMMED when the headlights are on ?
(that's when you would need it the most, when it's dark)
Alternately, you can wire the backlight to the common of a small relay powered by the headlight voltage with two contact pins connected as follows:
N.C. - backlight on normal brightness
N.O - Backlight dimmed.
When the headlights are off the backlight will be connected to +5V through an 82 ohm resistor connected to the anode. (cathode is grounded)
when the headlights are ON, the backlight is anode is connected to +5V through a much larger resistor
like 1 k ohm or something less.
I suppose you could use a 12V SPDT relay with one end of the coil connected to the car's +12V and
the other end of the coil connected to the headlight relay so when it is grounded it will ground the coil for the added relay too.
Thanks for that. I hadn't considered using an attiny. I just ordered a couple of these attiny boards which have an arduino boot loader and usb hardware pre installed.
The kickstarter ATtinyISP is much more useful. I incorporated one into my ATmega328/ATtiny85 Programmer project.
The SPDT relay would probably be simpler but if you have enough experience to know how to program an ATtiny85, you could just order one for $1.50 , program it and use that. It gives you much more flexability if you mount it in a socket so you can change your firmware whenever you want to modify the program. I buy 6 at a time. I'm running arduino IDE v 1.66 with DrAzzy's Board Manager that I got from here. so I can program the ATtiny85 with any frequency up to 20 Mhz (1,8, 16 , 20). If you have the skills to handwire a protoboard or make a pcb , it makes much more sense to build a programmer like mine but use a 14 pin ZIFF SOCKET, so you don't have to screw around prying the chip out of a socket with a tiny screwdriver
FYI,
I've use a PWM pin with an RC LPF of 4.7 k ohm resistor in series with the PWM pin to a 4.7 uF cap connected from the other end of the resistor to GND to the anode of the backlight led and it works just fine (cathode connected to GND).
Wiring up a protoboard/strip board isn't a big problem, I just went with that attiny board I linked to save effort programming chip myself (I've programmed other atmega chips before)
I really wanted to avoid using a relay, as I'd rather keep the system as solid state as I can.
raschemmel:
Why do you want to dim lcd when headlightss are on ?
Because that is what you do with automotive displays. You need them to be bright in daylight, but dimmer at night.
Arduinox or PWM have nothing to do with this. You select a resistor value to put in series with pin 15 (LED +) of the module to set the "dim" brightness, then use a PNP transistor (emitter to V+, collector to pin 15) to bypass it when its 10k base resistor which goes to the headlight circuit, is held at ground with the headlights off. When the headlights are on, the transistor is reverse biased (best add a diode in series with the base) and the resistor limits the LED current.
septillion:
But may I ask, what is driving the LCD? And doesn't that device have two spare pins?
The display is being driven by an uno. There are two challenges. The first is that the display will be mounted remotely from the controller and connected using 8 core stp (cat 5 cable) plus a power connection. All eight cores are already allocated to driving the lcd, handling a couple of buttons and an alarm buzzer.
The display is mounted close to a headlight switched source which was connected to the original instrumentstion in the location anyway, so running a short additional connection just for that isn't problem.
The second challenge is that I am concerned about program memory on the Arduino. So, while I have some spare pins, I don't want to add more code to the device it if I don't need to.
Most generic 4-bit lcds are used with an 80 ohm to 100 ohm in series with the +5V because the backlight led runs on 4.2V. You can simply use a 2n2222 transistor with a 470 ohm base resistor, emitter to GND, and an 80 ohm resistor in series with the led Anode pin and the cathode connected to ground so the backlight current is sinked by the transistor and PWM the base resistor with a PWM pin.
I've use a PWM pin with an RC LPF of 4.7 k ohm resistor in series with the PWM pin to a 4.7 uF cap connected from the other end of the resistor to GND to the anode of the backlight led and it works just fine (cathode connected to GND).
Arduinox or PWM have nothing to do with this
Both of the above methods work, but your suggestion is simpler by taking advantage of the active LOW nature of PNP transistor base junctions. As you pointed out, no code is necessary, but the fact that your suggestion is easier doesn't mean it can't be done with an arduino, it's just not necessary.
Why do you want to dim lcd when headlightss are on ?
Because that is what you do with automotive displays. You need them to be bright in daylight, but dimmer at nigh