CRTI_Progs / Mbed 2 deprecated USBJoystick_HelloWorld3

Dependencies:   USBDevice mbed

Fork of USBJoystick_HelloWorld by Wim Huiskamp

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 USBKeyboard keyboard;
00005 
00006 // Variables for Heartbeat and Status monitoring
00007 DigitalOut myled1(LED1);
00008 DigitalOut myled2(LED2);
00009 DigitalOut myled3(LED3);
00010 DigitalOut heartbeatLED(LED4);
00011 
00012 DigitalIn  mic (p14);
00013 
00014 Serial pc(USBTX, USBRX); // tx, rx
00015 
00016 
00017 char state;
00018 int main(){
00019  //   pc.printf("%u\n\r",);
00020     while (1) {
00021         if((state==0)&(mic==1)){
00022             state=1;
00023    //         pc.printf("oui\n\r");
00024              keyboard.keyCode2(0x00,0x10,0);     //sends touche CTRL  through the keyboard
00025              myled1=1;
00026         }else{  
00027              if(mic==0){
00028                     state=0;
00029                     keyboard.key_release();// release
00030                     myled1=0;
00031              }
00032         }
00033         wait(0.20);
00034     }
00035     
00036 }