C++ Code for the final project, to write input data from the joystick to the serial port through the mbed.
Revision 0:173425de07bf, committed 2016-12-12
- Comitter:
- spoda
- Date:
- Mon Dec 12 04:46:52 2016 +0000
- Commit message:
- C++ Code for the final project, to write input data from the joystick to the serial port through the mbed.
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
diff -r 000000000000 -r 173425de07bf main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Dec 12 04:46:52 2016 +0000 @@ -0,0 +1,25 @@ +#include "mbed.h" + +Serial pc(USBTX, USBRX); +DigitalIn Up(p24); +DigitalIn Left(p26); +DigitalIn Right(p28); +DigitalIn Down(p27); + +int main() { + while(1) { + if (Up.read() == 0) { + pc.printf("u\n"); + } + else if (Down.read() == 0) { + pc.printf("d\n"); + } + else if (Left.read() == 0) { + pc.printf("l\n"); + } + else if (Right.read() == 0) { + pc.printf("r\n"); + } + wait(0.2); + } +} \ No newline at end of file
diff -r 000000000000 -r 173425de07bf mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Dec 12 04:46:52 2016 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/d75b3fe1f5cb \ No newline at end of file