Connect USB HID Barcode Scanner and Scan any product. Add a case for storing your products in the database

Dependencies:   USBHost mbed

Fork of USBHostKeyboard_HelloWorld by Samuel Mokrani

Files at this revision

API Documentation at this revision

Comitter:
samux
Date:
Wed Mar 06 17:05:32 2013 +0000
Child:
1:2063e3713a99
Commit message:
USBHostKeyboard Hello World

Changed in this revision

USBHost.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBHost.lib	Wed Mar 06 17:05:32 2013 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/USBHost/#a554658735bf
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Mar 06 17:05:32 2013 +0000
@@ -0,0 +1,34 @@
+#include "mbed.h"
+#include "USBHostKeyboard.h"
+
+DigitalOut led(LED1);
+
+void onKey(uint8_t key) {
+    printf("%c\r\n", key);
+}
+
+void keyboard_task(void const *) {
+    
+    USBHostKeyboard keyboard;
+    
+    while(1) {
+        // try to connect a USB keyboard
+        while(!keyboard.connect())
+            Thread::wait(500);
+    
+        // when connected, attach handler called on keyboard event
+        keyboard.attach(onKey);
+        
+        // wait until the keyboard is disconnected
+        while(keyboard.connected())
+            Thread::wait(500);
+    }
+}
+
+int main() {
+    Thread keyboardTask(keyboard_task, NULL, osPriorityNormal, 256 * 4);
+    while(1) {
+        led=!led;
+        Thread::wait(500);
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Mar 06 17:05:32 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/5e5da4a5990b
\ No newline at end of file