This article was translated to English, and was originally published for deviceplus.jp.
Today, I’ll be introducing a different way to use Arduino. At first glance, it looks like the Arduino Pro Mini used in our previous series, but this Arduino is actually a different type. It’s called the “Arduino Pro Micro.” Although the Mini became the Micro, the size hasn’t changed at all, so it’s a little difficult to distinguish between the two. However, this Arduino is different once it’s connected to a PC since it can detect your mouse and keyboard like an HID (Human Interface Device).
Electronic work recipe
Table of contents
Arduino Pro Micro is an Arduino equipped with a chip called ATmega32U4 (UNO etc. is equipped with ATmega328P etc.). This chip’s biggest characteristic is being able to pretend that it’s a human interface device (HID), such as using a keyboard and mouse when connected by USB. Arduino equipped with ATmega32U4 is famous for the Arduino Leonardo board in addition to Pro Micro.
When writing a program, you can select and write a board called “Arduino Leonardo.”
Arduino Pro Mini at a glance next to the similar-looking Arduino Pro Micro.
However, Pro Micro has a USB connector that can be connected to a smartphone, etc., compared to Pro Mini with a serial connector.
Let’s try having the similar-looking Arduino Pro Micro read the sample program and try to get the computer to recognize it as an HID.
Try to run Arduino IDE’s “File”-“Sketch Example”-“09.USB”-“Keyboard”-“KeyboardMessage” program.
In this program, create a simple circuit with a switch on the 4th pin. When the 4th pin is pressed, the number of times pressed should be displayed by keyboard input.
(This time, I changed from Pin 4 to Pin 7)
After writing a program and opening a notepad, every time you press a button, it’ll count up with the above description without touching the keyboard.
If you can make a USB device this easily, then you can dream big!
Now that we know that it can be used as an HID, I’d like to make a mouse device by combining it with some other parts. This time, I’ll use a joystick that I used once for radio control production, and try to make it a device that can be used as a mouse with a joystick and tact switch.
First, prepare a program that you can use to set up the directions for the joystick.
The circuit will be added to the previous tact switch circuit. The joystick and the LED to be used later are
connected to the 2nd pin.
Looks like we were able to confirm that it read the program since the digits change as you rotate the joystick.
Let’s actually convert the joystick digits to mouse coordinates. This program is actually already prepared on the sample, so let’s use it. Select “File”-“Sketch Example”-“09.USB”-“Mouse”-“JoystickMouseControl.”
When this program is executed, the top and bottom analog A2 pins and the left and right A1 pin numbers are reflected on the mouse coordinates. In addition, since a switch is turned on by turning on the 5V power supply to No.2, the device can be turned on/off by connecting No.2 to VCC or sandwiching the switch.
Once you’ve written the program, try moving it.
Oh, it’s actually moving!
This time, we learned the basic process to make a USB device with Arduino using Arduino Pro Micro. Next time, I’ll take it to a more challenging level by trying to make a USB device look like device plus!