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 4DGL-uLCD-SE HC_SR04_Ultrasonic_Library
Diff: main.cpp
- Revision:
- 17:b8b68ff5e33a
- Parent:
- 16:5250c9fe0408
- Child:
- 18:7b1d65b007ab
--- a/main.cpp Sun Apr 26 13:32:42 2020 +0000
+++ b/main.cpp Sun Apr 26 17:56:57 2020 +0000
@@ -1,9 +1,9 @@
#include "mbed.h"
#include "rtos.h"
-//#include "SDFileSystem.h"
+#include "SDFileSystem.h"
#include "uLCD_4DGL.h"
#include "ultrasonic.h"
-//#include "wave_player.h"
+#include "wave_player.h"
#include "SongPlayer.h"
//#include <stdio.h>
@@ -11,7 +11,7 @@
uLCD_4DGL uLCD(p13, p14, p12); // Initialize uLCD serial tx, serial rx, reset pin;
-//SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card
+SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card
RawSerial blue(p9,p10); //Initialize Blutooth
//Serial BT(p9,p10);
@@ -96,10 +96,10 @@
serial_mutex.lock();
uLCD.cls();
dist.lock();
- uLCD.printf("Sonar Distance:\n %d", sdist);
+ uLCD.printf("Sonar Distance:\n %d\n Counter: %d \n Song: %d", sdist, counter, musicChoice);
dist.unlock();
serial_mutex.unlock();
- Thread::wait(1000); //Allow time to read value before reprint
+ Thread::wait(100); //Allow time to read value before reprint
}
}
@@ -107,6 +107,7 @@
void sounds(void const *arguments)
{
int last_counter = 0;
+ //FILE *wave_file;
// setup instance of new SongPlayer class, mySpeaker using pin 26
// the pin must be a PWM output pin
SongPlayer mySpeaker(p26);
@@ -115,23 +116,30 @@
while(1) {
if (counter > last_counter) {
switch (musicChoice) {
- case '0':
+ case 0:
+ printf("Beep\r\n");
//do nothing
break;
- case '1':
+ case 1:
+ //wave_file=fopen("/sd/test.wav","r");
+ //if(wave_file==NULL) {printf("file open error!\n\n\r");}
+ //waver.play(wave_file);
+ //fclose(wave_file);
mySpeaker.PlaySong(note1,duration);
break;
- case '2':
+ case 2:
mySpeaker.PlaySong(note2,duration);
break;
- case '3':
+ case 3:
mySpeaker.PlaySong(note3,duration);
break;
default:
+ printf("Invalid Choice\r\n");
break;
}
+ last_counter = counter;
}
- last_counter = counter;
+ //printf("Last Counter: %d\r\n",last_counter);
Thread::wait(100);
}
}