Arduino released the Nano R4 on July 25, 2025, powered by the same RA4M1 microcontroller that’s at the core of the popular UNO R4 boards. The board features 256 kB Flash, 32 kB SRAM and an 8 kB EEPROM, all running at 48 MHz with a built-in real-time clock (RTC), 14-bit ADC and a 12-bit DAC. In addition to a standard set of peripherals it also features UCB-C with HID support, CAN, a built-in OPAMP and the standard Qwiic I²C Connector.
The form factor is the same as other Nanos although the storage and speed have increased significantly. The focus for this article is on the USB HID functionality supported by this new design, along with the ability to create a simple keyboard wedge using the Nano R4.

Keyboard Wedge
A keyboard wedge is a device that uses HID to mimic a keyboard without one being present. This is a common use case in industrial applications such as barcode scanners, sensor logging, and various automations when inputs are required. No special software is needed as the computer thinks it is a keyboard that is plugged in and making the inputs. This feature of the new design can also be used to make a mouse wedge which would mimic a mouse’s inputs on a computer. Any program that has an area to input text (Excel, Chrome, Word, Notepad, etc.) can be used with an HID like the Arduino Nano R4.
Keyboard Wedge Example
To illustrate the capability and functionality of the wedge, a demonstration has been built using the following:
- Arduino Nano R4
- Tactile Button
- Ultra-sonic Sensor
If the button is pressed, the reading from the ultra-sonic sensor is read and formatted into a line like this “Distance: X cm” where the X is the current distance measured by the sensor. If I were to open any area on my computer in which text can be entered, Excel for example, then the above line would print into a new cell on each cycle. The speed can also be changed within the code, which can be found below.
This logic can be applied to many other use cases and sensors. The user can decide how they need their keyboard wedge to work. As mentioned previously, a mouse wedge is also an option, though it is often not as practical except in some niche cases. A sample code is provided to see the effect of a mouse wedge, in a fun way! This code spirals the mouse in and out as long as the Arduino Nano is connected to the PC, the code can be found below.
Keyboard Wedge Code
#include <Keyboard.h>
#define LOOP_TIME_MS 500
const int trigPin = 3;
const int echoPin = 4;
const int buttonPin = 2;
void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(buttonPin, INPUT_PULLUP); // Use internal pull-up resistor
Keyboard.begin();
delay(1000); // Wait for USB to stabilize
}
void loop() {
// Check if button is pressed (LOW due to pull-up config)
if (digitalRead(buttonPin) == LOW) {
long duration;
int distance;
// Send ultrasonic pulse
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Read echo time
duration = pulseIn(echoPin, HIGH);
// Calculate distance in cm
distance = duration * 0.034 / 2;
// Send distance as keystrokes
Keyboard.print("Distance: ");
Keyboard.print(distance);
Keyboard.println(" cm");
// Debounce delay so it doesn't repeat too fast
delay(LOOP_TIME_MS);
}
}
Mouse Wedge Code
#include <Mouse.h>
#include <math.h>
float angle = 0.0;
float radius = 0.0;
const float maxRadius = 50.0;
const float minRadius = 5.0;
const float angleStep = 0.3;
const float radiusStep = 0.1;
bool expanding = true;
void setup() {
Mouse.begin();
delay(1000); // Let USB settle
}
void loop() {
// Calculate position in polar coordinates
int dx = int(radius * cos(angle));
int dy = int(radius * sin(angle));
// Move the mouse
Mouse.move(dx, dy, 0);
// Advance angle
angle += angleStep;
// Adjust radius
if (expanding) {
radius += radiusStep;
if (radius >= maxRadius) expanding = false;
} else {
radius -= radiusStep;
if (radius <= minRadius) expanding = true;
}
delay(10);
}
Conclusion
The Arduino, with its small form factor and relatively easy coding environment can be used in many ways to automate anything the user needs. Whether it be for a personal project or a business or industrial need, an HID keyboard wedge can save the user time and money at scale.
DMC can implement HID Keyboard Wedges into your specific needs. Learn more about our Embedded expertise and contact us today.