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

Dependencies:   DebounceIn USBDevice mbed

Fork of idd_hw3_dpcinci_FUJICAR by Dominic Cincione

main.cpp

Committer:
dpcinci
Date:
2014-09-29
Revision:
2:c67ad98122e0
Parent:
1:7b6bc8042945

File content as of revision 2:c67ad98122e0:

#include "mbed.h"
#include "USBMouse.h"
#include "DebounceIn.h"

//Serial pc(USBTX, USBRX);

AnalogIn xAxis(A3);
AnalogIn yAxis(A4);

DebounceIn go(D4);


DigitalOut led2(LED2);
DigitalOut led1(LED1);
DigitalOut led(LED3);

float x = 0;
float y = 0;

float xStatic = 0.71;
float yStatic = 0.71;

int i = 50;

uint8_t throttle;

USBMouse mouse;


int main() {
    
    xStatic = 0.7;
    yStatic = 0.7;
    

    while(i--){
        xStatic = xAxis.read();
        yStatic = yAxis.read();
        led = 0;
        
        wait(0.01);
        }
        
        led = 1;
    
while(1) {
        
        throttle = !go.read();
        
        if(throttle==1){
            led2 = 0;
            led1 = 1;
            }
        if(throttle==0){
            led2 = 1;
            led1 = 0;
            }
        
        x = (xAxis.read()-xStatic)*50;
        y = (yAxis.read()-yStatic)*(-50);
        
        mouse.move(x,y);
         
        mouse.press(throttle);    
        
        /*        
        if(go == 0){
            G_led = 0;
            R_led = 1;
            }
            
        if(go==1){
            G_led = 1;
            R_led = 0;
            }
        */            
                    
        wait(0.01);    
            
    }
}