posted an update

Our main file for the ARM mbed system looked a bit like this, very simple;

Serial pc (USBTX, USBRX);
//Device PIN specification
//SERIAL_TX=PA_2  I2C_SCL=PB_8  SPI_MOSI=PA_7  PWM_OUT=PB_3
//SERIAL_RX=PA_3  I2C_SDA=PB_9  SPI_MISO=PA_6
//                              SPI_SCK =PA_5
//                              SPI_CS  =PB_6

AnalogIn xAxis(A0);
AnalogIn yAxis(A1);
PwmOut pwm(PB_3);

int x,y,button;  // global variables to hold values
Ticker joystick; // recurring interrupt to get joystick data

void joystick_Int_Handler()
{
    x = xAxis.read() * 1000; // float (0->1) to int (0-1000)
    y = yAxis.read() * 1000;
    if ( (x > 900) || (y > 900) )
        button = 1;
    else
        button = 0;     
}

int main() 
{

    pwm.period(0.050);
    // init interrupt, call every .2s
    joystick.attach(joystick_Int_Handler,0.2);
    // Print out the variables

    while(1){

        if(x < 800 && 600 < x && y < 800 && 600 < y ){
            pwm.pulsewidth(0.0015);
        }
        else if(x > 800 && y > 800 ){
            pwm.pulsewidth(0.00175);
        }
        else if(x < 600 && y < 600 ){
            pwm.pulsewidth(0.00125);
        }
        else if(x > 800 && y < 600 ){
            pwm.pulsewidth(0.00125);
        }
        else if(x < 600 ){
            pwm.pulsewidth(0.0025);
        }
        else if(y < 600 ){
            pwm.pulsewidth(0.001);
        }
        else if(y > 800 ){
            pwm.pulsewidth(0.002);
        }
        else if(x > 800 ){
            pwm.pulsewidth(0.0015);
        }
        pc.printf("\rX=%3d,Y=%3d",x,y);
    }

}

Log in or sign up for Devpost to join the conversation.