NerdKits - electronics education for a digital generation

You are not logged in. [log in]

NEW: Learning electronics? Ask your questions on the new Electronics Questions & Answers site hosted by CircuitLab.

Basic Electronics » Question on LCD screen

March 29, 2012
by billtaichi
billtaichi's Avatar

I have been going through the Tutorial for the nerdkit, I did the temperature sensor and it worked fine, then I took the temp sensor out and put in the LED for the next tutorial, but I left my LCD hooked up, I thought while it was blinking the LED I would show the text ON and OFF, changing for each one.

What I found was it would say OFF but ON never showed, the LED was blinking fine but ON never showed, I left that and added another LED and had it alternate it's on and off with the other LED but now I noticed nothing would show on the LCD screen. The pins powering the LED's were not connected to the LCD screen but if a light is on then the screen seems to be powered off. Anyone know what is going on? Can you not show the LCD screen if something else is powered by an output pin?

Here is my code (PC4 and PC3 are the pins my LEDs were connected to)

// led_blink.c
// for NerdKits with ATmega168
// hevans@nerdkits.edu

#define F_CPU 14745600

#include <avr/io.h>
#include <inttypes.h>

#include "../libnerdkits/delay.h"
#include "../libnerdkits/lcd.h"
#include <avr/pgmspace.h>

// PIN DEFINITIONS:
//
// PC4 -- LED anode

int main() {

lcd_init();

lcd_home();

  // LED as output
  DDRC |= (1<<PC4);
  DDRC |= (1<<PC3);

  // loop keeps looking forever
  while(1) {
    // write message to LCD THIS NEVER SHOWS SEEMS TO POWER LCD OFF
    lcd_home();
    lcd_write_string(PSTR("ON"));

    // turn on LED
    PORTC |= (1<<PC4);

    PORTC &= ~(1<<PC3);

    //delay for 500 milliseconds to let the light stay on
    delay_ms(500);

    // turn off LED
    PORTC &= ~(1<<PC4);
    PORTC |= (1<<PC3);
    lcd_home();
    lcd_write_string(PSTR("OFF"));

    //delay for 500 milliseconds to let the light stay off
    delay_ms(500);

  }

  return 0;
}
March 29, 2012
by Rick_S
Rick_S's Avatar

Sounds like your LED's are drawing the power down to where the LCD won't operate. If that is the issue then a solution would be to make sure you use a new battery or AC to DC power adapter and use current limiting resistors on your LED's.

Rick

March 29, 2012
by billtaichi
billtaichi's Avatar

Thanks Rick, I had tested the voltage of my battery and it was 9.3 volts but I put a new battery on anyway and that fixed it.

March 29, 2012
by Ralphxyz
Ralphxyz's Avatar

billtaichi, you probable needed to test your battery under load. You can get a tremendous difference in voltage between a battery with no load and one under load, lighting LEDs and LCDs.

Ralph

March 30, 2012
by billtaichi
billtaichi's Avatar

Thanks Ralph, now you have me curious, I did not test the old battery under load, will give that a shot to see how it differs from the good battery.

Post a Reply

Please log in to post a reply.

Did you know that you can connect digital calipers to a microcontroller? Learn more...