Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define F_CPU 8000000UL
- #include <avr/io.h>
- #include <util/delay.h>
- #define R1 3
- #define Y1 4
- #define G1 5
- #define R2 6
- #define Y2 7
- #define G2 8
- #define R3 9
- #define Y3 10
- #define G3 11
- #define R4 12
- #define Y4 13
- #define G4 2
- void setup(){
- for(int i =2; i <= 13; i++)
- pinMode(i, OUTPUT);
- DDRB = 0xff;
- DDRD = 0xff;
- DDRC = 0x00;
- PORTB = 0x00;
- PORTD = 0x00;
- }
- void loop()
- {
- if((PINC&0x01) == 0x01)
- {
- PORTB |= (1<<G1);
- PORTB |= (1<<Y2);
- PORTD |= (1<<R3);
- PORTD |= (1<<R4);
- }
- else if((PINC&0x02) == 0x02)
- {
- PORTB |= (1<<R1);
- PORTB |= (1<<G2);
- PORTD |= (1<<Y3);
- PORTD |= (1<<R4);
- }
- else if((PINC&0x04) == 0x04)
- {
- PORTB |= (1<<R1);
- PORTB |= (1<<R2);
- PORTD |= (1<<G3);
- PORTD |= (1<<Y4);
- }
- else if((PINC&0x08) == 0x08)
- {
- PORTB |= (1<<Y1);
- PORTB |= (1<<R2);
- PORTD |= (1<<R3);
- PORTD |= (1<<G4);
- }
- else
- {
- PORTB = 0x00;
- PORTD = 0x00;
- PORTB |= (1<<G1);
- PORTB |= (1<<Y2);
- PORTD |= (1<<R3);
- PORTD |= (1<<R4);
- _delay_ms(7000);
- PORTB = 0x00;
- PORTD = 0x00;
- PORTB |= (1<<R1);
- PORTB |= (1<<G2);
- PORTD |= (1<<Y3);
- PORTD |= (1<<R4);
- _delay_ms(7000);
- PORTB = 0x00;
- PORTD = 0x00;
- PORTB |= (1<<R1);
- PORTB |= (1<<R2);
- PORTD |= (1<<G3);
- PORTD |= (1<<Y4);
- _delay_ms(7000);
- PORTB = 0x00;
- PORTD = 0x00;
- PORTB |= (1<<Y1);
- PORTB |= (1<<R2);
- PORTD |= (1<<R3);
- PORTD |= (1<<G4);
- _delay_ms(7000);
- PORTB = 0x00;
- PORTD = 0x00;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement