It begins
Dependencies: SDFileSystem mbed-rtos mbed wave_player
Fork of BAT_senior_design by
main.cpp
- Committer:
- aismail1997
- Date:
- 2017-10-13
- Revision:
- 6:1aa86ad19af9
- Parent:
- 4:cc181f8f2bd1
- Child:
- 9:418a4437a693
File content as of revision 6:1aa86ad19af9:
#include "mbed.h" #include "functions.cpp" #include "rtos.h" PwmOut myservo(p21); DigitalIn pb1 (p20); //AnalogIn linpot(p20); Serial pc(USBTX, USBRX); //DigitalOut myled(LED1); SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card AnalogOut DACout(p26); wave_player waver(&DACout); // add start, mode, reset buttons // THREADS void button_thread() { } void submit_thread() { } void start_thread() { // read pb_start // if 1 start == 1; // else 0 } int main() { // SETUP // button up: state = 0, button halfway: state = 1; button down: state = 2 int state = 2; // pull up the pushbutton to prevent bouncing pb1.mode(PullUp); wait(.001); // servo begins at 30 degrees for(int i=0; i<=3; i++) { myservo = i/100.0; wait(0.01); } // MAIN THREAD while(true) { // start threads for reset, mode, start Thread t1(start_thread); // setup SDcard and Speaker // when started while (start == 0) {} Thread t2(button_thread); Thread t3(submit_thread); // when submitted while (submit == 0) {} // start button threads and submit thread // if submit close button threads and submit thread // check result, speaker result // save results // Servo code if (pb1 == 1 && state == 2) { moveServoIn(myservo, pb1); state = 1; } // rotate 90 degrees other way if (pb1 == 1 && state == 1) { moveServoOut(myservo, pb1); state = 2; } // SD card code // speaker code // read linear potentiometer //if (linpot < 0.5) { //float potval = linpot; //pc.printf("linear pot: %f\n", potval); } }