Working read code with mode button
Dependencies: SDFileSystem emic2 mbed-rtos mbed
Fork of BAT_senior_design_Testnew by
Diff: main.cpp
- Revision:
- 11:418a4437a693
- Parent:
- 8:1aa86ad19af9
- Child:
- 12:21268d8bf979
--- a/main.cpp Fri Oct 13 15:44:04 2017 +0000 +++ b/main.cpp Fri Oct 13 15:48:24 2017 +0000 @@ -1,6 +1,7 @@ #include "mbed.h" -#include "functions.cpp" #include "rtos.h" +#include "wave_player.h" +#include "SDFileSystem.h" PwmOut myservo(p21); DigitalIn pb1 (p20); @@ -12,8 +13,39 @@ wave_player waver(&DACout); // add start, mode, reset buttons +int start = 0; +int submit = 0; +// FUNCTIONS +void moveServoIn(PwmOut servo, DigitalIn pb) +{ + while(pb == 1) + //myled = 1; + // rotate 90 degrees one way + for(int i=3; i<=7; i++) { + servo = i/100.0; + wait(0.01); + } +} + +void moveServoOut(PwmOut servo, DigitalIn pb) +{ + while(pb == 1) + //myled = 0; + for(int i=7; i>3; i--) { + servo = i/100.0; + wait(0.01); + } +} + +void playSound(wave_player waver) +{ + FILE *wave_file; + wave_file=fopen("/sd/police_siren.wav","r"); + waver.play(wave_file); + fclose(wave_file); +} // THREADS