A robot rover with distance sensing and audiovisual effects

Dependencies:   4DGL-uLCD-SE Motordriver PID mbed

Fork of PIDRover by Aaron Berk

Revision:
4:48f440b9a787
Parent:
3:905643e72bcd
Child:
5:a8f6ac485b5d
--- a/main.cpp	Wed Mar 16 06:38:03 2016 +0000
+++ b/main.cpp	Wed Mar 16 06:52:07 2016 +0000
@@ -11,6 +11,7 @@
 #include "motordriver.h"
 #include "PID.h"
 #include "uLCD_4DGL.h"
+#include "SongPlayer.h"
 //one full revolution=193 counts
 
 
@@ -58,9 +59,11 @@
 DigitalOut led(LED1), led2(LED2);
 AnalogIn ain(p15);
 uLCD_4DGL uLCD(p28,p27,p29); // serial tx, serial rx, reset pin;
+float note[18]= {1568.0,1396.9,1244.5};
+float duration[18]= {0.48,0.24,0.72};
 
 int main() {
-    uLCD.printf("\nHello World\n"); //Default Green on black text
+    uLCD.printf("\nI must find Ben Kenobi!\n"); //Default Green on black text
     
     //Input and output limits have been determined
     //empirically with the specific motors being used.
@@ -75,6 +78,7 @@
     rightPid.setOutputLimits(0.0, 0.8);
     rightPid.setMode(AUTO_MODE);
     Serial pc(USBTX, USBRX);
+    SongPlayer mySpeaker(p23);
     
     int leftPrevPulses  = 0, leftActPulses=0; //The previous reading of how far the left wheel
     float leftVelocity  = 0.0; //The velocity of the left wheel in pulses per
@@ -85,7 +89,7 @@
     led=0;
     led2=0;
 
-    wait(0.5); //Wait a few seconds before we start moving.
+    wait(1); //Wait a few seconds before we start moving.
     uLCD.cls();
     uLCD.locate(1,2);
     uLCD.printf("I go straight!");
@@ -114,7 +118,8 @@
             rightMotor.stop(0.5);
             led2=1;
             uLCD.locate(1,2);
-            uLCD.printf("I'm turning!");
+            uLCD.printf("Ben Kenobi is not here!");
+            mySpeaker.PlaySong(note,duration);
             wait(0.5);
             leftPid.setSetPoint(-500);
             rightPid.setSetPoint(500);