Game controller for FUJI CAR driving game. Dominic Cincione, Zach Gima, Max Micali.

Dependencies:   DebounceIn USBDevice mbed

Fork of mouseTest by Code sharing

Committer:
dpcinci
Date:
Mon Sep 29 05:28:32 2014 +0000
Revision:
2:c67ad98122e0
Parent:
1:7b6bc8042945
Game controller for FUJI CAR driving game.  Dominic Cincione, Zach Gima, Max Micali.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dpcinci 0:e23fabfe5cbd 1 #include "mbed.h"
dpcinci 0:e23fabfe5cbd 2 #include "USBMouse.h"
dpcinci 2:c67ad98122e0 3 #include "DebounceIn.h"
dpcinci 0:e23fabfe5cbd 4
dpcinci 0:e23fabfe5cbd 5 //Serial pc(USBTX, USBRX);
dpcinci 0:e23fabfe5cbd 6
dpcinci 0:e23fabfe5cbd 7 AnalogIn xAxis(A3);
dpcinci 0:e23fabfe5cbd 8 AnalogIn yAxis(A4);
dpcinci 0:e23fabfe5cbd 9
dpcinci 2:c67ad98122e0 10 DebounceIn go(D4);
dpcinci 2:c67ad98122e0 11
dpcinci 0:e23fabfe5cbd 12
dpcinci 2:c67ad98122e0 13 DigitalOut led2(LED2);
dpcinci 2:c67ad98122e0 14 DigitalOut led1(LED1);
dpcinci 2:c67ad98122e0 15 DigitalOut led(LED3);
dpcinci 0:e23fabfe5cbd 16
dpcinci 0:e23fabfe5cbd 17 float x = 0;
dpcinci 0:e23fabfe5cbd 18 float y = 0;
dpcinci 0:e23fabfe5cbd 19
dpcinci 0:e23fabfe5cbd 20 float xStatic = 0.71;
dpcinci 0:e23fabfe5cbd 21 float yStatic = 0.71;
dpcinci 0:e23fabfe5cbd 22
dpcinci 0:e23fabfe5cbd 23 int i = 50;
dpcinci 0:e23fabfe5cbd 24
dpcinci 2:c67ad98122e0 25 uint8_t throttle;
dpcinci 0:e23fabfe5cbd 26
dpcinci 0:e23fabfe5cbd 27 USBMouse mouse;
dpcinci 0:e23fabfe5cbd 28
dpcinci 2:c67ad98122e0 29
dpcinci 0:e23fabfe5cbd 30 int main() {
dpcinci 0:e23fabfe5cbd 31
dpcinci 0:e23fabfe5cbd 32 xStatic = 0.7;
dpcinci 0:e23fabfe5cbd 33 yStatic = 0.7;
dpcinci 0:e23fabfe5cbd 34
dpcinci 2:c67ad98122e0 35
dpcinci 0:e23fabfe5cbd 36 while(i--){
dpcinci 0:e23fabfe5cbd 37 xStatic = xAxis.read();
dpcinci 0:e23fabfe5cbd 38 yStatic = yAxis.read();
dpcinci 2:c67ad98122e0 39 led = 0;
dpcinci 0:e23fabfe5cbd 40
dpcinci 0:e23fabfe5cbd 41 wait(0.01);
dpcinci 0:e23fabfe5cbd 42 }
dpcinci 0:e23fabfe5cbd 43
dpcinci 2:c67ad98122e0 44 led = 1;
dpcinci 0:e23fabfe5cbd 45
dpcinci 0:e23fabfe5cbd 46 while(1) {
dpcinci 2:c67ad98122e0 47
dpcinci 2:c67ad98122e0 48 throttle = !go.read();
dpcinci 2:c67ad98122e0 49
dpcinci 2:c67ad98122e0 50 if(throttle==1){
dpcinci 2:c67ad98122e0 51 led2 = 0;
dpcinci 2:c67ad98122e0 52 led1 = 1;
dpcinci 2:c67ad98122e0 53 }
dpcinci 2:c67ad98122e0 54 if(throttle==0){
dpcinci 2:c67ad98122e0 55 led2 = 1;
dpcinci 2:c67ad98122e0 56 led1 = 0;
dpcinci 2:c67ad98122e0 57 }
dpcinci 2:c67ad98122e0 58
dpcinci 0:e23fabfe5cbd 59 x = (xAxis.read()-xStatic)*50;
dpcinci 1:7b6bc8042945 60 y = (yAxis.read()-yStatic)*(-50);
dpcinci 0:e23fabfe5cbd 61
dpcinci 0:e23fabfe5cbd 62 mouse.move(x,y);
dpcinci 2:c67ad98122e0 63
dpcinci 2:c67ad98122e0 64 mouse.press(throttle);
dpcinci 0:e23fabfe5cbd 65
dpcinci 2:c67ad98122e0 66 /*
dpcinci 2:c67ad98122e0 67 if(go == 0){
dpcinci 2:c67ad98122e0 68 G_led = 0;
dpcinci 2:c67ad98122e0 69 R_led = 1;
dpcinci 0:e23fabfe5cbd 70 }
dpcinci 0:e23fabfe5cbd 71
dpcinci 1:7b6bc8042945 72 if(go==1){
dpcinci 2:c67ad98122e0 73 G_led = 1;
dpcinci 2:c67ad98122e0 74 R_led = 0;
dpcinci 0:e23fabfe5cbd 75 }
dpcinci 2:c67ad98122e0 76 */
dpcinci 0:e23fabfe5cbd 77
dpcinci 0:e23fabfe5cbd 78 wait(0.01);
dpcinci 0:e23fabfe5cbd 79
dpcinci 0:e23fabfe5cbd 80 }
dpcinci 0:e23fabfe5cbd 81 }