Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed mbed-rtos SevenSegmentSerial HC_SR04_Ultrasonic_Library
Revision 11:1a6658a543e0, committed 2021-05-01
- Comitter:
- glanier9
- Date:
- Sat May 01 02:58:59 2021 +0000
- Parent:
- 10:a3796a403d28
- Commit message:
- Videoed version of the code. Reset check all the time was unable to work due to a system lockup.;
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r a3796a403d28 -r 1a6658a543e0 main.cpp
--- a/main.cpp Fri Apr 30 15:01:34 2021 +0000
+++ b/main.cpp Sat May 01 02:58:59 2021 +0000
@@ -15,6 +15,7 @@
Thread thread1;
Thread thread2;
+Thread thread3;
Serial pc(USBTX,USBRX);
DigitalOut led0(p5);
DigitalOut led1(p6);
@@ -89,6 +90,20 @@
rgbCtrl3 = 0;
}
+void false_speaker()
+{
+ while(1) {
+
+ speaker.period(1.0/B4NOTE);
+ speaker = 0.5;
+ Thread::wait(200);
+ speaker = 0;
+ speaker.period(1.0/B4NOTE);
+ speaker = 0.5;
+ Thread::wait(200);
+ }
+}
+
// Plays bleep for crossing finish line
void play_audio()
{
@@ -111,7 +126,11 @@
if (width[0] - distance >= threshold[0]) {
//pc.printf("Past starting line\n");
- led0 = 1;
+ rgbGreen = 0;
+ rgbRed = 1;
+ rgbCtrl1 = 1;
+ rgbCtrl2 = 1;
+ rgbCtrl3 = 1;
led1 = 0;
led2 = 0;
current_lap++;
@@ -227,10 +246,8 @@
sonar0.checkDistance();
if (current_lap) {
thread2.terminate();
- speaker = 0.5;
- speaker.period(1/B4NOTE);
+ thread3.start(&false_speaker);
while(1) {
- speaker = 0;
rgbCtrl1 = rgbCtrl2 = rgbCtrl3 = 0;
led0 = led1 = led2 = 0;
rgbRed = 0;
@@ -247,11 +264,11 @@
led1 = !led1;
led2 = !led2;
Thread::wait(200);
- //wait for start char from Pi
}
}
}
+
while(1) {
switch (track_state) {
case start:
@@ -277,6 +294,5 @@
Thread::wait(50);
}
}
- Thread::wait(50);
}
-}
\ No newline at end of file
+}