#define F_CPU 16000000UL
#include <avr/io.h>
#include <util/delay.h>
// 7 6 5 4 3 2 1 0 -> BIT POSITION
// 8 4 2 1 8 4 2 1 -> BIT SIZE (FOR HEX)
// 0 0 0 0 0 0 0 0 ->
// 0 0 0 1 1 1 0 0 -> 1C
// Table for for digit from 0-9
// correspomding pins(a=2, b=3, c= 4, d=5, e=6, f=7, g=8)
uint8_t digit[10] = {
// gfedcba (bit order: 7 segments, g=bit6 ... a=bit0)
0b1000000, // 0 → a,b,c,d,e,f ON, g OFF
0b1111001, // 1 → b,c ON
0b0100100, // 2 → a,b,d,e,g ON
0b0110000, // 3 → a,b,c,d,g ON
0b0011001, // 4 → b,c,f,g ON
0b0010010, // 5 → a,c,d,f,g ON
0b0000010, // 6 → a,c,d,e,f,g ON
0b1111000, // 7 → a,b,c ON
0b0000000, // 8 → all ON
0b0010000 // 9 → a,b,c,d,f,g ON
};
void showNumber(uint8_t num){
}
int main (void){
DDRB |= (1 << PB4) | (1 << PB3) | (1 << PB2) | (1 << PB0); // PB4, PB3, PB2 & PB0 mark as OUTPUT
DDRD |= (1 << PD2) | (1 << PD3) | (1 << PD4) | (1 << PD5) | (1 << PD6) | (1 << PD7) // PD2 all to PD7 OUTPUT
PORTB &= ~((1 << PB0) | (1 << PB2) | (1 << PB3) | (1 << PB4)); // clear PB4, PB3, PB2 & PB0
PORTD &= ~((1 << PD2) | (1 << PD3) | (1 << PD4) | (1 << PD5) | (1 << PD6) | (1 << PD7))
while(1){
PORTB |= (1 << PB4); // RED LIGHT ON
PORTB &= ~(1 << PB4);
// _delay_ms(500);
PORTB |= (1 << PB3);
_delay_ms(500);
PORTB &= ~(1 << PB3);
// _delay_ms(500);
PORTB |= (1 << PB2);
_delay_ms(500);
PORTB &= ~(1 << PB2);
_delay_ms(500);
}
}