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.
main.cpp
00001 #include "mbed.h" 00002 #include "USBKeyboard.h" 00003 00004 DigitalOut Led1(LED1); 00005 PwmOut Led2(LED2); 00006 DigitalOut Led3(LED3); 00007 DigitalOut Led4(LED4); 00008 00009 InterruptIn Master(p10); 00010 InterruptIn Pulses(p12); 00011 00012 Serial pc(USBTX, USBRX); 00013 USBKeyboard keyboard; 00014 00015 int Count = 0; 00016 00017 void eMaster1() { 00018 Count=0; 00019 Led1=0; 00020 Led3=0; 00021 Led2=0; 00022 Led4=0; 00023 } 00024 00025 void eMaster0() { 00026 00027 } 00028 00029 void ePulse1() { 00030 00031 } 00032 00033 void ePulse0() { 00034 wait(0.1); 00035 Count++; 00036 00037 Led1 = (Count & 1 ? 1 : 0); 00038 Led2 = (Count & 2 ? 1 : 0); 00039 Led3 = (Count & 4 ? 1 : 0); 00040 Led4 = (Count & 8 ? 1 : 0); 00041 } 00042 00043 int main() { 00044 Master.rise(& eMaster1); 00045 Pulses.rise(& ePulse1); 00046 Master.fall(& eMaster0); 00047 Pulses.fall(& ePulse0); 00048 00049 while(1) 00050 { 00051 if(Master==0 and Count>0) 00052 { 00053 if (Count == 10) Count=0; 00054 //pc.putc(Count+48); 00055 if (Count == 0) keyboard.sendKey('0'); 00056 if (Count == 1) keyboard.sendKey('1'); 00057 if (Count == 2) keyboard.sendKey('2'); 00058 if (Count == 3) keyboard.sendKey('3'); 00059 if (Count == 4) keyboard.sendKey('4'); 00060 if (Count == 5) keyboard.sendKey('5'); 00061 if (Count == 6) keyboard.sendKey('6'); 00062 if (Count == 7) keyboard.sendKey('7'); 00063 if (Count == 8) keyboard.sendKey('8'); 00064 if (Count == 9) keyboard.sendKey('9'); 00065 00066 Led4= !Led4; 00067 Count=0; 00068 } 00069 } 00070 }
Generated on Fri Jul 15 2022 09:55:47 by
