idd hw3

Dependencies:   mbed DebounceIn USBDevice PinDetect

main.cpp

Committer:
pgao
Date:
2014-09-26
Revision:
3:6b5158c413b9
Parent:
0:84cb4cb4f860

File content as of revision 3:6b5158c413b9:

#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());
    }
}