boolean sw1;
boolean sw2;
void Dlay(){
delay(50);
}
void swoff(){
PORTD = B10000000;
PORTB = B00000010;
Dlay();
PORTD = B01000000;
PORTB = B00000001;
Dlay();
PORTD = B00101000;
PORTB = B00000000;
Dlay();
PORTD = B00010100;
PORTB = B00000000;
Dlay();
PORTD = B00001000;
PORTB = B00000001;
Dlay();
}
void sw1on(){
PORTD = B00111100;
PORTB = B00000000;
delay(100);
PORTD = B00000000;
PORTB = B00000000;
delay(100);
}
void sw2on(){
PORTD = B11000000;
PORTB = B00000011;
delay(100);
PORTD = B00000000;
PORTB = B00000000;
delay(100);
}
void setup()
{
DDRD = DDRD | B11111100; //Data Direction Register for Port D 1 means output
DDRB = DDRB | B00000011; //Data Direction Register for Port B 1 means output
/* This is the same as written above
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, INPUT);
pinMode(11, INPUT);
*/
}
void loop()
{
sw1=digitalRead(10);
sw2=digitalRead(11);
if (sw2 == false){
sw2on();
}
if (sw1 == false){
sw1on();
}
if (sw1 == true && sw2 == true){
swoff();
}
}