Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save raghavendrahassy/acb131278a135a1c5b8ae6f7da9b2512 to your computer and use it in GitHub Desktop.
Save raghavendrahassy/acb131278a135a1c5b8ae6f7da9b2512 to your computer and use it in GitHub Desktop.
#include <avr/io.h>
#include <util/delay.h>
#define Segment PD0
int main() {
char seg_code[]={0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e};
int cnt;
/* Configure the ports as output */
DDRB = 0xff; // Data
//DDRD |= (1 << Segment ); // Control signal PORTD0
DDRD = (1 << Segment);
while (1)
{
for (cnt = 0x00; cnt < 0x0f; cnt++) // loop to display 0-F
{
PORTD = ( 1<< Segment);
PORTB = seg_code[cnt];
_delay_ms(1000);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment