Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define F_CPU 16000000UL
- #define DISPLAY 4
- #include <avr/io.h>
- #include <util/delay.h>
- unsigned char segmets[] = {0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x83,0xc6,0xa1,0x86,0x8e} ;
- unsigned int io[] = {0x01, 0x02, 0x04, 0x08} ;
- unsigned int num, digit, a;
- unsigned char i;
- int main()
- {
- num = 1234;
- i= 0;
- DDRA = 0xff;
- DDRB = (1<<PA0) |(1<<PA1)|(1<<PA2)|(1<<PA3);
- while(1)
- {
- if(i <= DISPLAY)
- {
- a = num%10;
- PORTA= segmets[a];
- PORTB = io[i++];
- }
- else
- {
- i=0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement