Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: TSI TextLCD mbed
Fork of TextLCD_HelloWorld by
Diff: main.cpp
- Revision:
- 3:89a90f3245fd
- Parent:
- 2:ad0b044d0a10
--- a/main.cpp Sat Dec 04 11:31:07 2010 +0000 +++ b/main.cpp Fri May 03 08:31:29 2013 +0000 @@ -1,10 +1,64 @@ -// Hello World! for the TextLCD - #include "mbed.h" +#include "TSISensor.h" #include "TextLCD.h" -TextLCD lcd(p15, p16, p17, p18, p19, p20); // rs, e, d4-d7 +TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7 int main() { - lcd.printf("Hello World!\n"); -} + +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(); + } +} \ No newline at end of file