Jonathan Young
/
Rock_Paper_Scissors
XBee Rock Paper Scissors
main.cpp
- Committer:
- JonathanYoung22193
- Date:
- 2015-10-27
- Revision:
- 0:4e3027168064
File content as of revision 0:4e3027168064:
#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 "); } } }