Joystick test for Stage 1 Engineering at the University of York

Dependencies:   UoY-serial

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 int main()
00004 {
00005     AnalogIn x(A0);
00006     AnalogIn y(A1);
00007     DigitalIn button(D2, PullUp);
00008 
00009     // Loop forever...
00010     while (true) {
00011         // Always print out the X and Y values
00012         printf("x:%d y:%d\n", x.read_u16(), y.read_u16());
00013         if (button == false) {
00014             // If the button is being pressed, add a suitable message
00015              printf("\t(button pressed)\n");
00016         }
00017         thread_sleep_for(500);
00018     }
00019 }