Joystick example

Dependencies:   mbed

Fork of 1620_App_Board_Pots by Craig Evans

main.cpp

Committer:
eencae
Date:
2017-03-01
Revision:
2:4df3e4788aac
Parent:
1:d957f119593e

File content as of revision 2:4df3e4788aac:

/* ELEC1620 Application Board Example

Joystick

(c) Dr Craig A. Evans, University of Leeds, Feb 2017

*/

#include "mbed.h"

// these pins are shared by the potentiometers
AnalogIn  joy_v(p20);
AnalogIn  joy_h(p19);
AnalogIn joy_button(p17); // could be DigitalIn, but use AnalogIn so pot can also be used

int main() {
    
    while(1) {

        // read each of the pins              
        float x = joy_h.read();
        float y = joy_v.read();
        float button = joy_button.read();
                        
        // print over serial 
        printf("x = %.2f | y = %.2f | button = %.2f\n",x,y,button);
        
        // small delay between readings
        wait(0.2);
        
    }
}