55 #Eerste opzet: 26-11-2019 #
66 #Auteurs: E. Hammer | N. Vollebregt | M. Remmig | O. Cekem #
77 #Laatst gewijzigd: 23-01-2020 #
8- #Versie: 1.1.2 #
8+ #Versie: 1.1.3 #
99 #############################################################
1010
1111 ##WAT JE NIET MAG GEBRUIKEN##
@@ -86,6 +86,10 @@ void ServoSharpLeft(); // Prototype for the ServoSharpLeft function.
8686void ServoSharpRight (); // Prototype for the ServoSharpRight function.
8787void ServoBackward (); // Prototype for the ServoBackward function.
8888
89+ // Speaker
90+ int distanceSpeaker = 30 ; // Random value for testing purposes, pretending to have distance.
91+ int frequency; // Frequency variable.
92+
8993// Initializeren van de firmware
9094void setup () {
9195 Serial.begin (9600 ); // Start een serieële verbinding
@@ -142,7 +146,7 @@ void setup() {
142146}
143147
144148void loop () {
145- laserThreshold = ((analogRead (LDR0)+analogRead (LDR1)+analogRead (LDR2)+analogRead (LDR3)+analogRead (LDR4))/5 ) + 150 ; // Adaptive threshold waarde voor de richtingen
149+ laserThreshold = ((analogRead (LDR0)+analogRead (LDR1)+analogRead (LDR2)+analogRead (LDR3)+analogRead (LDR4))/5 ) + 120 ; // Adaptive threshold waarde voor de richtingen
146150algemeenLaserThreshold = (analogRead (LDR5)) + 50 ; // Adaptive threshold waarde voor algemeen
147151 distanceCheck ();
148152 // delay(500); //DEBUG
@@ -166,6 +170,8 @@ ISR(TIMER1_OVF_vect) {
166170
167171
168172void distanceCheck (void ) {
173+ // Delay for testing purposes.
174+ delay (100 );
169175 // AFSTAND SENSOR CHECKEN//
170176 float distanceCM;
171177 digitalWrite (ultraT, HIGH); // Pulse starten
@@ -179,18 +185,22 @@ void distanceCheck(void) {
179185 // delay(500); //DEBUG
180186 if (distanceCM >= 10 && distanceCM <=12 ) { // SFC 2.0
181187 ServoStop ();
188+ frequency = 1350 ; // High tone when standing still.
189+ tone (speaker, frequency);
182190 loop ();
183191 } else if (distanceCM > 12 ) { // SFC 2.1
192+ noTone (speaker);
184193 checkLDR ();
185194 } else if (distanceCM < 10 ) { // SFC 2.2
186195 ServoBackward ();
187196 Serial.println (" REVERSING...." );
197+ frequency = 700 ; // Lower tone when going backward.
198+ tone (speaker, frequency);
188199 // delay(500); //DEBUG
189200 loop ();
190201 }
191202}
192203
193-
194204void checkLDR () { // SFC 2.1
195205 // DEBUG
196206
0 commit comments