PWM HighRes (AVR) — Flowcode unofficial component
Posted: Mon Aug 24, 2026 11:55 pm
Edit: The updated component that simulates as well is here
PWM HighRes (AVR) — new Flowcode component
I've put together a new PWM component for Flowcode 11, built around AVR's Timer1, and it's now working and tested on real hardware across two device families.
What it does
Timer1 is the 16-bit timer on classic AVR chips, and this component drives it in Fast PWM mode with a dynamically calculated prescaler, giving a genuinely wide, accurate frequency range — roughly 1Hz to 300kHz
Supported devices
The component auto-detects which chip your project is targeting and adjusts itself accordingly — no manual configuration needed:
Duty cycle, at whatever resolution you need
Duty cycle is set entirely through function calls, at four different resolutions depending on how much precision you need:
Other functions
Confirmed working on an Uno, a RedBoard, and a Mega — covering both the 328P and 2560 pin mappings.
What's next
The next phase is adding a simulation-side visual: an oscilloscope-style simular to Flowcodes curremt PWM
More devices to add.
How to add the component to Flowcode
It will be found in Outputs > General Output
PWM HighRes (AVR) — new Flowcode component
I've put together a new PWM component for Flowcode 11, built around AVR's Timer1, and it's now working and tested on real hardware across two device families.
What it does
Timer1 is the 16-bit timer on classic AVR chips, and this component drives it in Fast PWM mode with a dynamically calculated prescaler, giving a genuinely wide, accurate frequency range — roughly 1Hz to 300kHz
Supported devices
The component auto-detects which chip your project is targeting and adjusts itself accordingly — no manual configuration needed:
- ATmega328P (Uno, Nano, RedBoard, and similar) — Output Pin choice of D9 (B1) or D10 (B2)
- ATmega2560 (Mega Including E-Blocks3 version) — Output Pin choice of D11 (B5), D12 (B6), or D13 (B7)
Duty cycle, at whatever resolution you need
Duty cycle is set entirely through function calls, at four different resolutions depending on how much precision you need:
- SetDutyCycle — 0 to 100 (percent, the simple option)
- SetDutyCycleByte — 0 to 255
- SetDutyCycle10Bit — 0 to 1023
- SetDutyCycle16Bit — 0 to 65535 (full resolution)
Other functions
- SetFrequency — 1 to 300,000 Hz
- Enable / Disable — Disable forces the output pin low without forgetting your last duty cycle or frequency; Enable picks up exactly where it left off
- Initialise — call once at startup; output starts at 0% duty until you call one of the SetDutyCycle functions
Confirmed working on an Uno, a RedBoard, and a Mega — covering both the 328P and 2560 pin mappings.
What's next
The next phase is adding a simulation-side visual: an oscilloscope-style simular to Flowcodes curremt PWM
More devices to add.
How to add the component to Flowcode
- Put the component file in a new folder — something like "Flowcode Custom Components" works well.
- Go to File > Global Settings > Locations tab > "Look for components in..." and add that folder's path. (If you add a semicolon at the end of the path, subfolders get included too.)
- Reload your project: File > Reload.
- To confirm Flowcode is actually using this version, go to Component Libraries, right-click the component, and select Details — it'll show you the folder it's loading from.
It will be found in Outputs > General Output