This example uses the Keyboard library to log you out of your user session on your computer when pin 2 on your Leonardo, Micro or Due is pulled to ground. The sketch simulates the keypress in sequence of two or three keys at the same time and after a short delay it releases them.
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 a Keyboard command after a pin has been pulled to ground.
Step 1: What You Need?
1 x Arduino Leonardo, Mirco, or Due Board
1 x Pushbutton
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 >> KeyboardLogout
Click press the "upload" button (see the button with right arrow mark).
Before you upload the program to your board, make sure to assign the correct OS you are currently using to the platform variable.
While the sketch is running, pressing the button will connect pin 2 to ground and the board will send the logout sequence to the USB connected pc.
Before you upload the program to your board, make sure to assign the correct OS you are currently using to the platform variable.
While the sketch is running, pressing the button will connect pin 2 to ground and the board will send the logout sequence to the USB connected pc.
0 comments:
Post a Comment