From 82eef68a1c01027e01c2dd42686bbe71550682c3 Mon Sep 17 00:00:00 2001 From: Romedius Weiss Date: Fri, 2 Nov 2018 01:13:34 +0100 Subject: [PATCH] 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. --- ITS_Open_direct_2fb/ITS_Open_direct_2fb.ino | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/ITS_Open_direct_2fb/ITS_Open_direct_2fb.ino b/ITS_Open_direct_2fb/ITS_Open_direct_2fb.ino index cfae4da..eb7c291 100644 --- a/ITS_Open_direct_2fb/ITS_Open_direct_2fb.ino +++ b/ITS_Open_direct_2fb/ITS_Open_direct_2fb.ino @@ -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);