![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
A program which uses twin DC motors and a lidar to drive a robot controlled by a gamepad through an mbed.
Test
This is a test of the repository
Diff: main.cpp
- Revision:
- 16:73a8f1db6f76
- Parent:
- 15:e012856b3a61
--- a/main.cpp Sat Nov 23 20:08:46 2019 +0000 +++ b/main.cpp Tue Nov 26 17:13:15 2019 +0000 @@ -14,6 +14,8 @@ Serial BT(p13,p14); Serial pc(USBTX,USBRX); BusOut led(p15,p16,p19,p18); +PwmOut spkr(p23); +DigitalOut spkrenable(p5); static XNucleo53L0A1 *board=NULL; bool stopMotor = false; @@ -45,7 +47,7 @@ if(turbo) motor->speed(mspeed); if(!turbo) - motor->speed(mspeed/1.75); + motor->speed(mspeed/1.25); } else motor->speed(0); @@ -105,6 +107,8 @@ lm.speed(0); rm.speed(0); led.write(0); + spkrenable = 0; + while (1) { status = board->sensor_centre->get_distance(&distance); @@ -114,7 +118,11 @@ if (distance < 300) { // Distance might need to be adjusted stopMotor = true; led.write(15*!led.read()); - wait(.1); + spkrenable = 1; + spkr = .5; + wait(.1); + spkr = 0; + spkrenable = 0; } else{ stopMotor = false;