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
main.cpp
00001 #include "mbed.h" 00002 #include "TSISensor.h" 00003 #include "TextLCD.h" 00004 00005 TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7 00006 00007 int main() { 00008 00009 TSISensor tsi; 00010 PwmOut gled(LED_GREEN); 00011 PwmOut bled(LED_BLUE); 00012 Serial pc(USBTX, USBRX); 00013 Timer t; 00014 00015 00016 bled = 1; 00017 gled = 1; 00018 00019 while(1) { 00020 float a; 00021 float b; 00022 float c; 00023 lcd.printf("READY,\n"); 00024 wait (1); 00025 lcd.cls(); 00026 lcd.printf("SET,\n"); 00027 wait (1); 00028 lcd.cls(); 00029 lcd.printf("GO!\n"); 00030 c = rand() %10000; 00031 a = 0; 00032 float time; 00033 for (time = 0; time < c; time+=0.01) 00034 { 00035 a = tsi.readPercentage(); 00036 if (a > 0) 00037 { 00038 lcd.printf("CHEAT!\n"); 00039 a=0; 00040 } 00041 } 00042 //wait(c); 00043 a = 0; 00044 bled = 0; 00045 t.start(); 00046 00047 while (a == 0) 00048 { 00049 00050 a = tsi.readPercentage(); 00051 } 00052 bled = 1; 00053 gled = 0; 00054 t.stop(); 00055 b = t.read(); 00056 lcd.cls(); 00057 lcd.printf("Reaction Time: %f\n", b); 00058 a = 0; 00059 wait(5); 00060 gled = 1; 00061 lcd.cls(); 00062 t.reset(); 00063 } 00064 }
Generated on Wed Jul 13 2022 22:48:06 by
1.7.2
