Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void setup()
- {
- DDRD = 0B11111100;
- DDRB = 0x01;
- Serial.begin(9600);
- // PORTD = 0xF8;
- // PORTB = 0x01;
- }
- int contor = 0, state = 0, old_state = 0;
- int state2 = 0, old_state2 = 0;
- void loop()
- {
- state = PINB & 0b00001000;
- if (state && (old_state == 0))
- {
- if (contor == 9)
- contor = 0;
- else
- contor++;
- }
- state2 = PINB & 0b00010000;
- if (state2 && (old_state2 == 0))
- {
- if (contor == 0)
- contor = 9;
- else
- contor--;
- }
- Serial.println(contor);
- switch (contor)
- {
- case 0:
- PORTD = 0xF8;
- PORTB = 0x01;
- break;
- case 1:
- PORTD = 0x48;
- PORTB = 0x00;
- break;
- case 2:
- PORTD = 0x9C;
- PORTB = 0x01;
- break;
- case 3:
- PORTD = 0x5C;
- PORTB = 0x01;
- break;
- case 4:
- PORTD = 0x6C;
- PORTB = 0x00;
- break;
- case 5:
- PORTD = 0x74;
- PORTB = 0x01;
- break;
- case 6:
- PORTD = 0xF4;
- PORTB = 0x01;
- break;
- case 7:
- PORTD = 0x58;
- PORTB = 0x00;
- break;
- case 8:
- PORTD = 0xFC;
- PORTB = 0x01;
- break;
- case 9:
- PORTD = 0x7C;
- PORTB = 0x01;
- }
- old_state = state;
- old_state2 = state2;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement