Simple dynamic LED display drive

I have got a simple 4 digit LED display routine. This is simulated using Proteus simulator. So in the picture you see simplified version of circuit. In real world you might need to strobe digits using transistor keys. Control program is written using WinAVR tool chain.

disp.JPG

Bellow is a complete C file

//—————————————————-

#include

#include

#include

#include

#include

#include

uint8_t numbers[]={

0b11000000,//0

0b11111001,//1

0b10100100,//2

0b10110000,//3

0b10011001,//4

0b10010010,//5

0b10000010,//6

0b11111000,//7

0b10000000,//8

0b10010000,//9

0b01111111//.

};

uint8_t i;

void initAmega8()

{

PORTD=0xFF; //Port D all to “1″ - LEDS OFF

DDRD=0xFF; //Port D all to output

//Port B control lines to “1″ - Transistors OFF

PORTB &=~((1<<<<

//Port B control lines as output

DDRB |=((1<<<<

}

void sendNumber(uint8_t digit, uint8_t position)

{

//0…9 for digit; 1..4 for position

PORTD=numbers[digit];

PORTB|=_BV(position-1);

_delay_us(100);

PORTB&=~_BV(position-1);

_delay_us(100);

}

int main(void)

{

initAmega8();

while(1)

{

sendNumber(2,1);//LCD display shows “2006″

sendNumber(0,2);

sendNumber(0,3);

sendNumber(6,4);

}

return 0;

}

//—————————————————-

Blogsphere: TechnoratiFeedsterBloglines
Bookmark: Del.icio.usSpurlFurlSimpyBlinkDigg
RSS feed for comments on this post
 |  TrackBack URI for this post

New on WinAVR Tutorial
Running TX433 and RX433 RF modules with AVR microcontrollers,
Sometimes in embedded design you may want to go wireless. Might be you will want to log various readi …
Programming AVR ADC module with WinAVR,
Most of AVR microcontrollers have Analog to Digital Converter (ADC) integrated in to chip. Such solut …
New on WinARM Tutorial
What are differences between WinARM and WinAVR,
Everyone who is working with AVR microcontrollers knows this powerful tool – WinAVR (http://win …
LPC2000 watchdog timer,
As in all microcontrollers watchdog timers purpose isto reset microcontroller after reasonable amount …

Leave a Reply