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: PinDetect Ulrasonic mbed-rtos mbed WTV020SD_Sound_Breakout_Library
Fork of MC by
Revision 37:22ce2b4040f7, committed 2016-09-23
- Comitter:
- benrammok
- Date:
- Fri Sep 23 13:05:48 2016 +0000
- Parent:
- 36:3011c70a5c81
- Commit message:
- Added WTV020 Sound Library and Control Structure for Distance Detection and Audio Playback
Changed in this revision
--- a/WTV020M01.lib Thu Sep 22 13:48:34 2016 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -http://mbed.org/users/benrammok/code/WTV020M01/#b602eec7b6c1
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/WTV020SD_Sound_Breakout_Library.lib Fri Sep 23 13:05:48 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/ejteb/code/WTV020SD_Sound_Breakout_Library/#d6b7b90b4387
--- a/main.cpp Thu Sep 22 13:48:34 2016 +0000
+++ b/main.cpp Fri Sep 23 13:05:48 2016 +0000
@@ -1,19 +1,18 @@
#include "mbed.h"
#include "rtos.h"
#include "PinDetect.h"
-#include "WTV020M01.h"
+#include "soundboard.h"
#include "ultrasonic.h"
//Needs to be define to be able to read from the Ultrasonic sensor
void dist(int);
-ultrasonic mu(A2, A3, .1, 1, &dist); //Set the trigger pin to D8 and the echo pin to D9
+ultrasonic mu(PB_0, PA_0, .1, 1, &dist); //Set the trigger pin to D8 and the echo pin to D9
//have updates every .1 seconds and a timeout after 1
//second, and call dist when the distance changes
+soundboard sndBoard(PG_1, PF_9, PF_7, PF_8); // Defines the WTV020M01 Soundboard
Serial pc(USBTX, USBRX); // tx, rx
-WTV020M01 sndBoard(PB_13, PB_14, PB_15, PB_1, NC); // NUCLEO F334R8
-//WTV020M01 sndBoard(PG_1, PF_9, PF_7, PF_8, NC); // Soundboard - NUCLEO F746ZG
//MidMagnetSensors
PinDetect pb3(D10);
PinDetect pb4(D11);
@@ -482,7 +481,7 @@
{
while(true)
{
-
+
sDistance = mu.getCurrentDistance();
Thread::wait(100);
dDistance = mu.getCurrentDistance();
@@ -490,31 +489,20 @@
printf("Current Distance: %dmm\r\n", sDistance);
printf("Current Change in Distance: %dmm\r\n", abs(sDistance-dDistance));
if(abs(sDistance-dDistance) > 30 && abs(sDistance-dDistance) < 1000){
- /* Control structure for different audio playback.
- sndBoard.nextTrack();
- sndBoard.nextTrack();
- sndBoard.nextTrack();
-
- if(sDistance >= 500){
- sndBoard.resetTrack();
- Thread::wait(200);
- sndBoard.nextTrack();
- Thread::wait(200);
- sndBoard.nextTrack();
+ if(dDistance >= 1000){
+
+ }else if(dDistance < 1000 & dDistance >=750) {
+ sndBoard.play(0000);
}
- if(sDistance < 500){
- sndBoard.resetTrack();
- Thread::wait(200);
- sndBoard.nextTrack();
- Thread::wait(200);
- sndBoard.nextTrack();
- Thread::wait(200);
- sndBoard.nextTrack();
- isPlaying = true;
+ else if(dDistance < 750 & dDistance >=300) {
+ sndBoard.play(0001);
}
- */
- }
-
+ else if(dDistance < 300 & dDistance >=50) {
+ sndBoard.play(0002);
+ }else{
+ sndBoard.play(0003);
+ }
+ }
Thread::wait(200);
}
}
@@ -673,8 +661,8 @@
- mu.startUpdates();//start mesuring the distance
-
+ mu.startUpdates();//Start mesuring the distance
+ sndBoard.reset(); //Resets the sound board
pb1.mode(PullUp);
--- a/mbed.bld Thu Sep 22 13:48:34 2016 +0000 +++ b/mbed.bld Fri Sep 23 13:05:48 2016 +0000 @@ -1,1 +1,1 @@ -http://mbed.org/users/mbed_official/code/mbed/builds/252557024ec3 \ No newline at end of file +http://mbed.org/users/mbed_official/code/mbed/builds/abea610beb85 \ No newline at end of file
