HW3- swrd

Dependencies:   PinDetect_KL25Z USBDevice mbed

Fork of octasword by TONY WU

main.cpp

Committer:
twuster
Date:
2015-09-16
Revision:
2:082bca930f40
Parent:
1:bce67ae4dbab
Child:
3:0251fef04954

File content as of revision 2:082bca930f40:

#include "mbed.h"
#include "PinDetect.h"
#include "USBKeyboard.h"

Serial pc(USBTX, USBRX);

AnalogIn x_in(A0);
AnalogIn y_in(A1);
AnalogIn z_in(A2);

//USBKeyboard keyboard;
PinDetect start_button(D6);
PinDetect up_button(D5);
PinDetect down_button(D4);
PinDetect right_button(D8);
PinDetect left_button(D7);

int main() {
    pc.printf("%s", "Welcome to octa sword");
    start_button.mode(PullUp);
    up_button.mode(PullUp);
    down_button.mode(PullUp);
    right_button.mode(PullUp);
    left_button.mode(PullUp);
    
    while(1) {
        if (start_button == 0) {
            keyboard.keyCode(32);
        } else if (up_button == 0) {
            keyboard.keyCode(32);
        } else if (down_button == 0) {
            keyboard.keyCode(32);
        } else if (right_button == 0) {
            keyboard.keyCode(32);
        } else if (left_button == 0) {
            keyboard.keyCode(32);
        }   
        
        pc.printf("x is: %f\n\r", x_in.read());
        pc.printf("y is: %f\n\r", y_in.read());
        pc.printf("z is: %f\n\r", y_in.read());
        wait(.1);
    }
}