Jesus Fausto
/
Joystick
Joy to the world
Diff: main.cpp
- Revision:
- 0:34022ad4a23d
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Fri Jul 13 22:24:30 2018 +0000 @@ -0,0 +1,24 @@ +#include "mbed.h" +#include "Joystick.h" + +// Xaxis,Yaxis,Button +Joystick joystick(PTB2, PTB3, PTB11); +DigitalOut r_led(LED_RED); +Serial pc(USBTX, USBRX); + +int main() +{ + //First initalise joystick + joystick.init(); + + while (true) { + + Vector2D coord = joystick.get_coord(); + pc.printf("Coord = x %3f\ty %3f\r\n",(coord.x+1)/2,(coord.y+1)/2); + //If the button flag is pressed switch the led +/* if (joystick.button_pressed()) { + pc.printf("button is pressed\t"); + r_led = !r_led; + }*/ + } +} \ No newline at end of file