idd hw3
Dependencies: mbed DebounceIn USBDevice PinDetect
Diff: main.cpp
- Revision:
- 3:6b5158c413b9
- Parent:
- 0:84cb4cb4f860
--- a/main.cpp Fri Sep 26 00:23:26 2014 +0000 +++ b/main.cpp Fri Sep 26 00:42:28 2014 +0000 @@ -1,12 +1,30 @@ #include "mbed.h" +#include "PinDetect.h" Serial pc(USBTX, USBRX); +PinDetect buttons[] = {D13, D12, D11, D10, D9, D8, D7, D6}; AnalogIn accelZ(A0); AnalogIn accelY(A1); AnalogIn accelX(A2); +int num_buttons = 8; + +void button0_hit_callback (void) { + pc.printf("asdf\n"); +} + int main() { + for (int i = 0; i < num_buttons; i++) { + buttons[i].mode(PullUp); + pc.printf("button %d is in pullup\n", i); + } + wait(0.01); + buttons[0].attach_deasserted(&button0_hit_callback); + for (int i = 0; i < num_buttons; i++) { + buttons[i].setSampleFrequency(); + } + while(1) { pc.printf("%f\n", accelY.read()); }