NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.
Microcontroller Programming » LCD turns off when a LED turns on
June 25, 2011 by arthurlol |
Hello, I'm starting with the NerdKits programming section and I wrote this simple code:
When I run it, in the moment the LED turns on, the LCD automatically turns off, after 500ms the "Test" comes back, and after 1 second (the moment when the LED turns on again), the LCD goes off. What am I doing wrong? What can I do to solve this? Thanks, everyone! |
---|---|
June 26, 2011 by Rick_S |
Could you post photo's of you circuit. It sounds as if you are creating too much current draw and losing the LCD because of the power used by the LED. If you are using a battery for power maybe try a new one, or go with a different power source. Another thing I recommend is using a current limiting resistor on your LED so it can only draw as much as you allow. I commonly use 1k resistors for this purpose and get plenty of light from the LED. |
June 26, 2011 by arthurlol |
Hello, Rick! Thanks for answering, I'll try to buy a new battery tomorrow, so I'll give a try. I just tested with a 1k resistor (which I'm not sure if it's connected on the right pins, can you check on the photo?), but I got no result, the same thing happens (the LCD turns off and on according to the LED status). I also tried to connect the circuit with my wall wart (which outputs 5.2V), but at this time, only the LED turned on, the LCD didn't display anything. Here's a photo of the circuit: |
June 26, 2011 by arthurlol |
By the way, as for the LCD not turning on at all when I connected with the wall wart, I presume it's because of the output (5.2V 770mA), right? |
June 26, 2011 by Ralphxyz |
I do not know if this would cause your problem but pin 20 and 21 should go to the red rail!! Or is that just the picture not showing the angle? This has nothing to do with your problem but you will probable learn that life is easier when you use different color wire for + and - I'd like to see your LCD header and the MCU. 5.2v should be ok, I do not know about the 770mA that might not be enough to run the mcu and the led and the lcd. Ralph |
June 26, 2011 by arthurlol |
I just found out I had a 9V adapter here, so I tried using it. And it WORKED! I didn't have to use a resistor on the LED though. Anyway, I'll try with a battery that I'll probably buy tomorrow too. Ralph, it's just the angle, both of them are connected to the red rail, sorry for the quality of photo, my bad! Thanks for the tip, buddy, I'll start to put this in practice! |
June 27, 2011 by Rick_S |
The reason the resistor on the LED did nothing was because it was not connected correctly. The resistor should have been MCU-PIN---RESISTOR---LED---PWR RAIL You had it +RAIL---RESISTOR---MCU-PIN---LED---GND-RAIL. Wired that way, the resistor would be pulling current when you turn off the LED and doing nothing when you turn it on. However, your LED would stil be able to draw whatever current the micro could put out. Also, 770mA should be more than enough current at 5.2V to run everything assuming the 5V was measured on your rail after the regulator. If the wall wart was 5.2VDC at 770mA, the voltage would not be high enough to be regulated (you need about 7VDC for the regulator to work proplerly) That would explain why your 9V adapter worked but the other one didn't. A standard (Not rechargeable) 9V is only rated at 150mA. (Unless things have changed with modernd alkaline technology) Remember 9V batteries are just comprised of a grouping of (6) 1.5v cells in series either AAAA cells or some flat stacked cell. The batteries current output is no greater than that of an individual cell. --- I guess what I'm taking the long way around to say --- if 770mA was not enough current, a 9V battery would never work because it puts out nowhere close to that amount. Rick |
Please log in to post a reply.
Did you know that you can connect digital calipers to a microcontroller? Learn more...
|