Arduino Keyboard and Mouse Control Code
This example illustrates the use of the Mouse and keyboard libraries together. Five momentary switches act as directional buttons for your cursor. When a button is pressed, the cursor on your screen will move, and a keypress will be sent to the computer. Once you have the Leonardo programmed and wired up, open up your favorite text editor to see the results.
NB: When you use these libraries, the Arduino takes over your computer’s keyboard and mouse!
- Any text editor
/* KeyboardAndMouseControl Controls the mouse from five pushbuttons on an Arduino Leonardo or Micro. Hardware: * 5 pushbuttons attached to D2, D3, D4, D5, D6 The mouse movement is always relative. This sketch reads four pushbuttons, and uses them to set the movement of the mouse. WARNING: When you use the Mouse.move() command, the Arduino takes over your mouse! Make sure you have control before you use the mouse commands. created 15 Mar 2012 modified 27 Mar 2012 by Tom Igoe this code is in the public domain */
For more detail: Arduino Keyboard and Mouse Control Code
JLCPCB – Prototype 10 PCBs for $2 + 2 days Lead Time
China’s Largest PCB Prototype Enterprise, 300,000+ Customers & 10,000+ Online Orders Per Day
Inside a huge PCB factory: https://www.youtube.com/watch?v=_XCznQFV-Mw
This Post / Project can also be found using search terms:
- how to use a wireless mouse to control an arduino robot