lcd reaction game
Dependencies: TSI TextLCD mbed
Fork of TextLCD_HelloWorld by
main.cpp
- Committer:
- ktitov
- Date:
- 2013-05-03
- Revision:
- 3:89a90f3245fd
- Parent:
- 2:ad0b044d0a10
File content as of revision 3:89a90f3245fd:
#include "mbed.h" #include "TSISensor.h" #include "TextLCD.h" TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7 int main() { TSISensor tsi; PwmOut gled(LED_GREEN); PwmOut bled(LED_BLUE); Serial pc(USBTX, USBRX); Timer t; bled = 1; gled = 1; while(1) { float a; float b; float c; lcd.printf("READY,\n"); wait (1); lcd.cls(); lcd.printf("SET,\n"); wait (1); lcd.cls(); lcd.printf("GO!\n"); c = rand() %10000; a = 0; float time; for (time = 0; time < c; time+=0.01) { a = tsi.readPercentage(); if (a > 0) { lcd.printf("CHEAT!\n"); a=0; } } //wait(c); a = 0; bled = 0; t.start(); while (a == 0) { a = tsi.readPercentage(); } bled = 1; gled = 0; t.stop(); b = t.read(); lcd.cls(); lcd.printf("Reaction Time: %f\n", b); a = 0; wait(5); gled = 1; lcd.cls(); t.reset(); } }