Keyboard based response box for E-prime Psychopy. This box has a certain latency determinated by os and debounce function delay.

Revision:
0:c1b31c5bc2cb
diff -r 000000000000 -r c1b31c5bc2cb keyTrigger.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/keyTrigger.cpp	Tue Nov 14 12:53:28 2017 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+#include "USBKeyboard.h"
+#include "keyTrigger.h"
+
+
+USBKeyboard keyboard;            //USBKeyboard
+bool toggleLED=true;
+/*
+ This function has 3 input parameters
+ char key
+ DigitalIn GPIO
+ delayms for debouncing
+
+*/
+
+
+      void keyTrigger (char key,  DigitalIn pinio, int delayms)
+    
+    {
+        
+
+        DigitalOut Blue(led_blue);
+        
+        
+        if (!pinio)                      //pinio pull up
+           {                
+             wait_ms(delayms);           // keypress debounce  
+              if (!pinio)
+              {
+                    toggleLED=!toggleLED; 
+                     keyboard.keyCode(key);
+                     Blue=toggleLED;
+                     wait_ms(delayms);
+                    //keyboard.keyCode(0x0a);      // Enter    
+                  
+              }
+           }  
+          
+    
+    }
\ No newline at end of file