Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 1. Spojit 7seg, znamenke na PORTB, segmente na PORTD
- 2. Key1 datum, Key2 godina
- */
- #define F_CPU 7372800UL
- #include <avr/io.h>
- #include <util/delay.h>
- int main(void)
- {
- DDRD = 0xff;
- PORTD = 0x00;
- DDRB = 0xf0;
- PORTB = 0x0f;
- uint8_t date[] = {0x5b, 0x5b, 0x3f, 0x4f};
- uint8_t year[] = {0x5b, 0x3f, 0x06, 0x07};
- uint8_t i, state = 0;
- while (1)
- {
- if(bit_is_clear(PINB, 0)){
- state = 1;
- PORTD = 0x00;
- PORTB = 0x03;
- }else if(bit_is_clear(PINB, 1)){
- state = 2;
- PORTD = 0x00;
- PORTB = 0x03;
- }
- if(state == 1){
- for(i = 0; i < 4; i++){
- PORTD = date[i];
- PORTB = _BV(4 + i);
- _delay_us(1000);
- }
- } else if(state == 2){
- for(i = 0; i < 4; i++){
- PORTD = year[i];
- PORTB = _BV(4 + i);
- _delay_us(1000);
- }
- }
- _delay_us(10); // za debounce
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement