Jonathan Young
/
Rock_Paper_Scissors
XBee Rock Paper Scissors
Revision 0:4e3027168064, committed 2015-10-27
- Comitter:
- JonathanYoung22193
- Date:
- Tue Oct 27 16:30:14 2015 +0000
- Commit message:
- hi
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/TextLCD.lib Tue Oct 27 16:30:14 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/simon/code/TextLCD/#e4cb7ddee0d3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Oct 27 16:30:14 2015 +0000 @@ -0,0 +1,122 @@ +#include "mbed.h" +#include "TextLCD.h" + +Serial xbee(USBTX, USBRX); + +TextLCD lcd(PTA13, PTD5, PTD0, PTD2, PTD3, PTD1, TextLCD::LCD16x2); // rs, e, d4-d7 + +DigitalIn enable1(PTA4); +DigitalIn enable2(PTA5); +DigitalIn enable3(PTC8); +DigitalIn enable4(PTC9); + +int main() { + char move; + lcd.locate(0,0); + lcd.printf("ROCK, PAPER, "); + lcd.locate(0,1); + lcd.printf("SCISSORS "); + while(1) { + if (enable1){ + xbee.printf("R"); + wait(.05); + if (xbee.readable()) { + move = xbee.getc(); + if (move == 'R'){ + lcd.locate(0,0); + lcd.printf("ROCK VS ROCK "); + lcd.locate(0,1); + lcd.printf("YOU TIED "); + } + if (move == 'P') { + lcd.locate(0,0); + lcd.printf("ROCK VS PAPER "); + lcd.locate(0,1); + lcd.printf("YOU LOST:( "); + } + if (move == 'S') { + lcd.locate(0,0); + lcd.printf("ROCK VS SCISSORS"); + lcd.locate(0,1); + lcd.printf("YOU WON!:) "); + } + if (move == 'E') { + lcd.locate(0,0); + lcd.printf("ROCK, PAPER, "); + lcd.locate(0,1); + lcd.printf("SCISSORS "); + } + } + } + if (enable2){ + xbee.printf("P"); + wait(.05); + if (xbee.readable()) { + move = xbee.getc(); + if (move == 'R'){ + lcd.locate(0,0); + lcd.printf("PAPER VS ROCK "); + lcd.locate(0,1); + lcd.printf("YOU WON!:) "); + } + if (move == 'P') { + lcd.locate(0,0); + lcd.printf("PAPER VS PAPER "); + lcd.locate(0,1); + lcd.printf("YOU TIED "); + } + if (move == 'S') { + lcd.locate(0,0); + lcd.printf("PAPER V SCISSORS"); + lcd.locate(0,1); + lcd.printf("YOU LOST:( "); + } + if (move == 'E') { + lcd.locate(0,0); + lcd.printf("ROCK, PAPER, "); + lcd.locate(0,1); + lcd.printf("SCISSORS "); + } + } + } + if (enable3) { + xbee.printf("S"); + wait(.05); + if (xbee.readable()) { + move = xbee.getc(); + if (move == 'R'){ + lcd.locate(0,0); + lcd.printf("SCISSORS VS ROCK"); + lcd.locate(0,1); + lcd.printf("YOU LOST:( "); + } + if (move == 'P') { + lcd.locate(0,0); + lcd.printf("SCISSORS V PAPER"); + lcd.locate(0,1); + lcd.printf("YOU WON!:) "); + } + if (move == 'S') { + lcd.locate(0,0); + lcd.printf("SCISS VS SCISS "); + lcd.locate(0,1); + lcd.printf("YOU TIED "); + } + if (move == 'E') { + lcd.locate(0,0); + lcd.printf("ROCK, PAPER, "); + lcd.locate(0,1); + lcd.printf("SCISSORS "); + } + } + } + if (enable4) { + xbee.printf("E"); + wait(.05); + lcd.locate(0,0); + lcd.printf("ROCK, PAPER, "); + lcd.locate(0,1); + lcd.printf("SCISSORS "); + } + } + } \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Oct 27 16:30:14 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/04dd9b1680ae \ No newline at end of file