Nucleo fade
analogWrite breathes an LED on D9 of an STM32 Nucleo-F411RE, at STM32duino’s 1 kHz PWM. The whole build, an STM32 Nucleo-F411RE and 2 more parts, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.
Teaching? Assign it to your class in one click.
Beginner Runs in your browser. Free, and no account needed.
The parts retail for about $16.15. On Mokxi they're free.
The code
The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.
// Fade: breathe an LED with PWM.
//
// Wire an LED and a 220 ohm resistor from D9 to GND. D9 is the STM32's PC7,
// which analogWrite drives from TIM3's second channel at 1 kHz, as STM32duino
// does. The PWM pins on the Nucleo's Arduino header are D3, D5, D6, D9, D10
// and D11, the same as an Uno's.
const int LED = 9;
void setup() {
pinMode(LED, OUTPUT);
}
void loop() {
for (int v = 0; v <= 255; v += 5) {
analogWrite(LED, v);
delay(20);
}
for (int v = 255; v >= 0; v -= 5) {
analogWrite(LED, v);
delay(20);
}
}
Parts list
4 parts, plus the jumper wires. They retail for about $16.15; on Mokxi they're free.
- 1 × STM32 Nucleo-F411RE
- 1 × Half breadboard
- 1 × Resistor, 220 Ω
- 1 × LED, red
How it is wired
3 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.
- Ground: STM32 Nucleo-F411RE pin GND; LED, red pin C
- STM32 Nucleo-F411RE pin D9; Resistor, 220 Ω pin 1
- Resistor, 220 Ω pin 2; LED, red pin A
Change it and keep it
Open it in the editor, change the circuit or the code, and keep your version in a free account.