TomYumBoys / Mbed 2 deprecated MM2017

Dependencies:   mbed

Committer:
kolanery
Date:
Sat May 13 21:27:32 2017 +0000
Revision:
4:73510c7fa316
Parent:
3:4230b82fde43
Child:
5:d783972dce10
update pid control

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kolanery 0:cb667de3a336 1 #include "drivecontrol.h"
kolanery 0:cb667de3a336 2 #include "pin_assignment.h"
kolanery 4:73510c7fa316 3 #include "io_modules.h"
kolanery 2:619b02232144 4
kolanery 0:cb667de3a336 5 // Define states for debugging the mouse hardware
kolanery 2:619b02232144 6 // const int DRIVE = 1, TURN = 2, DEBUG = 3, STOP = 4;
kolanery 0:cb667de3a336 7 // Direction of which to turn
kolanery 2:619b02232144 8 // const int LEFT = 0, RIGHT = 1;
kolanery 0:cb667de3a336 9 // Start and End Pos
kolanery 0:cb667de3a336 10 const int START_POS = 0, END_POS = 0;
kolanery 2:619b02232144 11
kolanery 0:cb667de3a336 12 // Terminating condition for the main control loop
kolanery 0:cb667de3a336 13 bool hasFoundCenter = false;
kolanery 0:cb667de3a336 14
kolanery 0:cb667de3a336 15 // Battery Consumption Indicator
kolanery 0:cb667de3a336 16 void setup() {
kolanery 0:cb667de3a336 17 pc.baud(9600);
kolanery 4:73510c7fa316 18 // using the serial functions will have an impact on timing.
kolanery 4:73510c7fa316 19 // serial.printf("voltage value is: %3.3f%%\r\n", battery.read()*100.0f);
kolanery 4:73510c7fa316 20 // serial.printf("normalized: 0x%04X \r\n", battery.read_u16());
kolanery 2:619b02232144 21 if (battery.read() < 0.67f){
kolanery 0:cb667de3a336 22 // flash led
kolanery 4:73510c7fa316 23 led_1 = 1;
kolanery 4:73510c7fa316 24 led_2 = 1;
kolanery 4:73510c7fa316 25 led_3 = 1;
kolanery 4:73510c7fa316 26 led_4 = 1;
kolanery 0:cb667de3a336 27 }
kolanery 0:cb667de3a336 28 }
kolanery 0:cb667de3a336 29
kolanery 0:cb667de3a336 30 // Performs the basic drive control of the mouse
kolanery 0:cb667de3a336 31 int main() {
kolanery 4:73510c7fa316 32 DriveControl * driver = new DriveControl (START_POS, END_POS);
kolanery 2:619b02232144 33 while(1) {
kolanery 2:619b02232144 34 setup();
kolanery 4:73510c7fa316 35 led_1 = 1;
kolanery 2:619b02232144 36 driver->drive_one_forward();
kolanery 3:4230b82fde43 37 wait(0.5);
kolanery 2:619b02232144 38 driver->stop();
kolanery 4:73510c7fa316 39 wait(10);
kolanery 0:cb667de3a336 40 }
kolanery 2:619b02232144 41 }