A robot rover with distance sensing and audiovisual effects
Dependencies: 4DGL-uLCD-SE Motordriver PID mbed
Fork of PIDRover by
Diff: main.cpp
- Revision:
- 5:a8f6ac485b5d
- Parent:
- 4:48f440b9a787
- Child:
- 6:9dc165a89453
--- a/main.cpp Wed Mar 16 06:52:07 2016 +0000 +++ b/main.cpp Wed Mar 16 07:24:04 2016 +0000 @@ -59,11 +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}; +float note[18]= {3520, 3135.96, 2637.02, 2093, 2349.32, 3951.07, 2793.83, 4186.01, 3520, 3135.96, 2637.02, 2093, 2349.32, 3951.07, 2793.83, 4186.01}; +float duration[18]= {0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1}; int main() { - uLCD.printf("\nI must find Ben Kenobi!\n"); //Default Green on black text + uLCD.printf("\n I am on an\n important\n mission!"); //Default Green on black text //Input and output limits have been determined //empirically with the specific motors being used. @@ -88,11 +88,12 @@ int distance = 0; //Number of pulses to travel. led=0; led2=0; + uLCD.baudrate(3000000); wait(1); //Wait a few seconds before we start moving. uLCD.cls(); uLCD.locate(1,2); - uLCD.printf("I go straight!"); + uLCD.printf("I must find\n Ben Kenobi!"); //Velocity to mantain in pulses per second. leftPid.setSetPoint(1000); @@ -117,10 +118,17 @@ leftMotor.stop(0.5); rightMotor.stop(0.5); led2=1; + uLCD.cls(); uLCD.locate(1,2); - uLCD.printf("Ben Kenobi is not here!"); + //uLCD.printf("He is not here!"); mySpeaker.PlaySong(note,duration); + uLCD.filled_circle(64, 64, 63, RED); + wait(0.2); + uLCD.filled_circle(64, 64, 63, 0x0000FF); wait(0.5); + uLCD.filled_circle(64, 64, 63, RED); + wait(0.3); + //wait(0.5); leftPid.setSetPoint(-500); rightPid.setSetPoint(500); @@ -138,11 +146,11 @@ }//Turning while end leftMotor.stop(0.5); rightMotor.stop(0.5); - wait(0.5); + wait(0.1); led2=0; uLCD.cls(); uLCD.locate(1,2); - uLCD.printf("I go straight!"); + uLCD.printf("I must find\n Ben Kenobi!"); leftPid.setSetPoint(1000); rightPid.setSetPoint(1000);