EE149
/
FinalProject
Final Project files for mBed development.
main.c
- Committer:
- lsaristo
- Date:
- 2014-11-16
- Revision:
- 11:a30f30d3066e
- Parent:
- 10:94b068b2ce1d
- Child:
- 12:1aa6b8a74136
File content as of revision 11:a30f30d3066e:
/** * @file driver.c * @brief Basic driver program for our robot's controller logic. * * Maybe add lots of stuff here or maybe split it off into * multiple subfiles? * * @author John Wilkey */ #include "main.h" #include "control.h" /** * These are global data Used externally in all other files */ m3pi pi; // // Digital inputs to the mBed DigitalIn start_button(p21); // // Digital outputs from the mBed. Note that by default these are // used to drive the 8 LED's on the top board. DigitalOut pin15(p15); DigitalOut pin16(p16); DigitalOut pin17(p17); DigitalOut pin18(p18); DigitalOut pin19(p19); DigitalOut pin20(p20); // // mBed onboard LEDs DigitalOut oled_1(LED1); DigitalOut oled_2(LED2); DigitalOut oled_3(LED3); DigitalOut oled_4(LED4); /** * @brief Entry point. Main loop. */ int main() { // // Basic setup information start_button.mode(PullUp); // // Main program loop. robot_loop(); // // We should never reach this point! } int forward(int amt) { oled_2 = 1; pi.locate(0,0); pi.printf("Fwd %d", amt); pi.forward(DRIVE_SPEED); wait(amt*DRIVE_RATE); oled_2 = 0; return EXIT_SUCCESS; } int backward(int amt) { oled_3 = 1; pi.locate(0,0); pi.printf("Back %d", amt); pi.backward(DRIVE_SPEED); wait(amt*DRIVE_RATE); oled_3 = 0; return EXIT_SUCCESS; } int right(float deg) { oled_4 = 1; pi.locate(0,0); pi.printf("Right %f", deg); pi.right(TURN_SPEED); wait(deg/360); oled_4 = 0; return EXIT_SUCCESS; } int left(float deg) { oled_4 = 1; oled_2 = 1; pi.locate(0,0); pi.printf("Left %f", deg); pi.left(TURN_SPEED); wait(deg/360); oled_4 = 0; oled_2 = 0; return EXIT_SUCCESS; } void pen_down() { oled_1 = 1; } void pen_up() { oled_1 = 0; }