Home > Net >  The arduino to rob people
The arduino to rob people

Time:10-10

Good sound buzzer, press the button lights and not go out for a long time, have a buzzer prompt
'The code
Int redled=12;//red LED output
Int yellowled=11;//yellow LED output
Int greenled=10;//green LED output
Int redpin=5;//red button pin
Int yellowpin=4;//yellow button pin
Int greenpin=3;//green button pin
Int Buzzer=7;
Int restpin=2;//reset button pin definition
Int red;
Int yellow;
Int green;
Int redpin_MUN=0;
Int greenpin_MUN=0;
Int yellowpin_MUN=0;
Void setup () {
PinMode (redled, the OUTPUT);
PinMode (yellowled, the OUTPUT);
PinMode (greenled, the OUTPUT);
PinMode (Buzzer, the OUTPUT);
PinMode (redpin, INPUT);
PinMode (yellowpin, INPUT);
PinMode (greenpin, INPUT);

DigitalWrite (Buzzer, LOW);
}
Void loop ()//button loop scanning,
{

Red=digitalRead (redpin);
If (red==LOW)
{
DigitalWrite (redled, LOW);
}
The else
{

DigitalWrite (redled, HIGH);
ScanKey2 ();
}

Yellow=digitalRead (yellowpin);
If (yellow==LOW)
{
DigitalWrite (yellowled, LOW);
}
The else
{
DigitalWrite (yellowled, HIGH);
ScanKey1 ();
}
Green=digitalRead (greenpin);
If (green==LOW)
{
DigitalWrite (greenled, LOW);
}
The else
{
DigitalWrite (greenled, HIGH);
ScanKey3 ();
}
}


Void ScanKey1 ()
{
Greenpin_MUN=0;
If (digitalRead (greenpin)==LOW)
{
//delay to jitter
If (digitalRead (greenpin)==LOW)
{
BuzzerDi ();//drop 1
Greenpin_MUN=1;//set keys
While (digitalRead (greenpin)==LOW);//let go test
}
}

}
Void ScanKey2 ()
{
Yellowpin_MUN=0;
If (digitalRead (yellowpin)==LOW)
{
//delay to jitter
If (digitalRead (yellowpin)==LOW)
{
BuzzerDi ();//drop 1
Yellowpin_MUN=1;//set keys
While (digitalRead (yellowpin)==LOW);//let go test
}

}

}
Void ScanKey3 ()
{
Redpin_MUN=0;
If (digitalRead (redpin)==LOW)
{
//delay to jitter
If (digitalRead (redpin)==LOW)
{
BuzzerDi ();//drop 1
Redpin_MUN=1;
While (digitalRead (redpin)==LOW);//let go test
}
}
}

Void BuzzerDi ()
{unsigned char (I);
DigitalWrite (Buzzer, HIGH);
delay(100);
DigitalWrite (Buzzer, LOW);

}






  • Related