I recently acquired the new Arduino UNO Q and I am running into a specific issue with PWM generation that seems to be related to the core/firmware.
The Setup:
Board: Arduino UNO Q.
Hardware: L298N Motor Driver connected to DC motors.
Power: External power for motors, common ground shared with Arduino.
The Problem: I am trying to control motor speed using analogWrite(). However, the pins do not output any PWM signal. The voltage remains static (LOW) regardless of the value passed (e.g., analogWrite(pin, 128)).
Troubleshooting steps I have already taken:
Tested multiple pins: I tried pins 3, 5, 6, and 9. None of them generate a variable voltage/duty cycle with analogWrite.
Hardware verification: I confirmed the wiring is correct by using digitalWrite(pin, HIGH). When using digitalWrite, the pins go HIGH correctly (3.3V), and the motors spin at full speed. This confirms the connection to the L298N is valid.
Resolution: I tried forcing analogWriteResolution(8) in setup(), but it made no difference.
Minimal Reproducible Example Code: Here is the simple test sketch I am using. digitalWrite works, analogWrite fails.
`const int pwmPin = 9; // Tested with 3, 5, 6, 9
void setup() {
pinMode(pwmPin, OUTPUT);
// analogWriteResolution(8); // Tried with and without this
}
void loop() {
// TEST 1: This DOES NOT work (Voltage stays 0V)
analogWrite(pwmPin, 128);
delay(1000);
// TEST 2: This WORKS (Voltage goes to 3.3V, Motor spins max speed)
// digitalWrite(pwmPin, HIGH);
// delay(1000);
}`
Has anyone else experienced this with the UNO Q? or is this a known bug in the current core version?
const int analogInPin = A0; // Analog input pin that the potentiometer is attached to
const int pwmOutPin = D3; // PWM output pin
int sensorValue = 0; // value read from the pot
int outputValue = 0; // value output to the PWM (analog out)
void setup() {
// Define the PWM output resolution
analogWriteResolution(10); // 0 - 1023 -> 0 - 100% duty-cycle
analogReadResolution(14); // 0 - 16383
}
void loop() {
// read the analog in value:
sensorValue = analogRead(analogInPin);
// map it to the range of the analog out:
outputValue = map(sensorValue, 0, 16383, 0, 1024);
// change the analog out value:
analogWrite(pwmOutPin, outputValue);
// wait 2 milliseconds before the next loop for the ADC
// to settle after the last reading:
delay(2);
}
On the UNO Q Zephyr core, analogWrite() expects to own the pin configuration. If you call pinMode() first, it **breaks PWM on that pin and you get exactly what you’re seeing: analogWrite() does nothing (0 V), but digitalWrite() still works. This is a known quirk/“feature” and has been reported on the Arduino forum; the official suggestion from the Arduino team was “remove pinMode and it will work.”Arduino Forum
Fix
Just let analogWrite() set the pin mode itself:
const int pwmPin = 9; // 3, 5, 6, 9 are fine PWM pins on UNO Q
void setup() {
// Do NOT call pinMode() for a PWM pin on UNO Q
// analogWriteResolution(8); // Optional; default is 8-bit anyway
}
void loop() {
analogWrite(pwmPin, 128); // ~50% duty, ~1.65V average on 3.3V logic
delay(1000);
}
This should fix it for you.
The Arduino developers are aware of the problem of pinMode being incompatible with analogWrite, and have already done some work towards a provisional fix: