![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Code to run the microcontrollers on the R5 competition bot
Dependencies: LineSensors mbed
DriveController.h
- Committer:
- Hypna
- Date:
- 2014-10-03
- Revision:
- 3:0d7687b6ef14
- Parent:
- 2:d0ce8e26cbc4
- Child:
- 4:ac6b2e5b240b
File content as of revision 3:0d7687b6ef14:
#ifndef DRIVECONTROLLER_H #define DRIVECONTROLLER_H #include "mbed.h" #include <list> #include <string> enum Direction { NORTH, SOUTH, EAST, WEST }; struct Command { Direction direction; int distance; }; class DriveController { private: DigitalOut wheel1; DigitalOut wheel2; DigitalOut wheel3; DigitalOut wheel4; List<DigitalInOut> sensors; const string sensorPinNames[] = {"PTC7", "PTC0", "PTC3", "PTC4", "PTC5", "PTC6", "PTC10", "PTC11", "PTC9", "PTC8", "PTA5", "PTA4", "PTA12", "PTD4", "PTA2", "PTA1", "PTC12", "PTC13", "PTC16", "PTC17", "PTD2M", "PTD0", "PTD5", "PTD13"} /*DigitalInOut sensor01; DigitalInOut sensor02; DigitalInOut sensor03; DigitalInOut sensor04; DigitalInOut sensor05; DigitalInOut sensor06; DigitalInOut sensor07; DigitalInOut sensor08; DigitalInOut sensor09; DigitalInOut sensor10; DigitalInOut sensor11; DigitalInOut sensor12; DigitalInOut sensor13; DigitalInOut sensor14; DigitalInOut sensor15; DigitalInOut sensor16; DigitalInOut sensor17; DigitalInOut sensor18; DigitalInOut sensor19; DigitalInOut sensor20; DigitalInOut sensor21; DigitalInOut sensor22; DigitalInOut sensor23; DigitalInOut sensor24; */ bool sensorStates[24]; Direction orientation; Command command; void move(); void getCommand(); void rotate(); void forward(); void readSensors(); double calculateError(); bool intersection(); public: DriveController(); void go(); }; #endif