Signal Analysis: Reading PWM Duty Cycle
We often output PWM signals to dim an LED or control a servo motor. But how does an Arduino read a PWM signal coming from another device, like an RC receiver or an industrial sensor? The Read Duty Cycle project acts as a simple, low-frequency oscilloscope.

The pulseIn() Function
While interrupts (ISRs) are the most accurate way, the simplest method is the native pulseIn() command.
- The High Pulse: The Arduino waits for the incoming pin to go HIGH, starts a microsecond timer, and waits for it to go LOW. That is the
time_high. - The Low Pulse: It does the same to measure
time_low. - The Math: The Duty Cycle percentage is calculated by:
Duty Cycle = (time_high / (time_high + time_low)) * 100.
Visuino: Visual Programming
For those who struggle with C++ syntax, this project is commonly taught using Visuino. Visuino is a drag-and-drop graphical environment.
- You drag a 'PulseIn' block onto the screen.
- You draw a wire connecting it to a 'Math Divider' block.
- You draw a wire sending the final result to a 'Serial Terminal' block. Visuino then automatically generates the complex C++ code in the background and uploads it to the board!
Required Hardware
- Arduino Uno/Nano: The analyzer.
- A 5V Signal Generator: This could be a 555-Timer chip, an RC car receiver, or a second Arduino generating
analogWrite(). - Visuino Software (Optional, but highly recommended for visual learners).