Added beeper to spaceping functionality
if the space is closed, it beeps once if the space is open, it beeps three times The beeper is connected to A5 and needs no PWM, only 5V to work.
This commit is contained in:
parent
71121944ce
commit
82eef68a1c
1 changed files with 20 additions and 0 deletions
|
@ -54,9 +54,27 @@ const int rlight = 6;
|
|||
const int topen = 2;
|
||||
const int tclose = 3;
|
||||
|
||||
const int beeper = A5;
|
||||
|
||||
void setLeds(){
|
||||
if (pingtimer>=0)
|
||||
{
|
||||
if(hsopen){ // If space is not closed, beep three times with
|
||||
//beep
|
||||
if((pingtimer> 220)&&((pingtimer/5)%2 ==1)){
|
||||
digitalWrite(beeper, HIGH);
|
||||
}else{
|
||||
digitalWrite(beeper, LOW);
|
||||
}
|
||||
|
||||
}else{ // if closed, beep once
|
||||
//beep
|
||||
if((pingtimer> 240)&&((pingtimer/5)%2 ==1)){
|
||||
digitalWrite(beeper, HIGH);
|
||||
}else{
|
||||
digitalWrite(beeper, LOW);
|
||||
}
|
||||
}
|
||||
// blink like crazy
|
||||
if((pingtimer/2)%2 ==1){
|
||||
analogWrite(rlight, 255);
|
||||
|
@ -286,6 +304,8 @@ void setup()
|
|||
|
||||
pinMode(glight, OUTPUT);
|
||||
pinMode(rlight, OUTPUT);
|
||||
pinMode(beeper, OUTPUT);
|
||||
digitalWrite(beeper,LOW);
|
||||
|
||||
// Buttons with pullup resistor
|
||||
pinMode(topen, INPUT);
|
||||
|
|
Reference in a new issue