This example uses the Keyboard library to open a new Arduino Software (IDE) sketch window, send keyboard commands that type in the Blink example, and reprograms the board. After running this sketch and connecting pin 2 to ground using the pushbutton, the board will have a new program, Blink.
NB: When you use the Keyboard.print() command, the Arduino takes over your computer's keyboard! To insure you don't lose control of your computer while running a sketch with this function, make sure to set up a reliable control system before you call Keyboard.print(). This sketch is designed to only send Keyboard commands after digital pin 2 is pulled to ground.
Step 1: What You Need?
1 x Arduino Leonardo, Mirco, or Due Board
1 x Pushbutton
Don't have components? Don't worry. Just click the component's name.
Step 2: Build Your Circuit.
Connect your board to the USB port, then push the button to connect D2 with GND and initiate the sketch keyboard keypress emulation.
Step 3: Upload The Code.
1. Select the Arduino board type: Select Tools >> Board >> Select your correct Arduino board used.2. Find the port number by accessing device manager on Windows. See the section Port (COM&LPT) and look for an open port named "Arduino Leonardo (COMxx)". If you are using a different board, you will find a name accordingly. What matters is the xx in COMxx part. In my case, it's COM3. So my port number is 3.
Select the right port: Tools >> Port >> Select the port number.
3. You can find this code in the example of Arduino IDE.
Select File >> Examples >> 09.USB >> Keyboard >> KeyboardReprogram
Click press the "upload" button (see the button with right arrow mark).
Remember to have the Arduino Software (IDE) window selected before you press the button.
0 comments:
Post a Comment