A optical beam breaker detector that appears to aPC as a USB keyboard, typing characters when the beam is broken

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "USBKeyboard.h"
00003 
00004 DigitalOut trigger(LED1);
00005 DigitalIn event(p22);
00006 USBKeyboard k;
00007 
00008 int main() {
00009     while (1) {
00010         trigger = event;
00011         if (event) {
00012             k.putc('|');
00013             trigger = event;
00014             wait(1);
00015             while (!event) {
00016                 trigger = event;
00017             }
00018         }
00019     }
00020 }