Exercise A: Blinky
~15 min
Your first hands-on exercise. You'll take a working blinky example and adapt it for the uFerris board.
Starting Point
Open the examples/blinky/ project in the workshop repo. This is a complete, working blinky that toggles a GPIO output.
Read through src/main.rs. You should see the Create → Configure → Control pattern:
#![allow(unused)] fn main() { // CREATE: instantiate an Output driver for a GPIO pin let mut led = Output::new( peripherals.GPIO0, // ← Which pin? This might not be right for uFerris Level::Low, // ← Initial state OutputConfig::default() // ← Default configuration ); // CONTROL: toggle the LED in a loop loop { led.toggle(); // delay... } }
Your Task
The example works — but it's using GPIO0, which might not be the LED on your uFerris board.
- Check your pinout card — which GPIO pin is connected to the onboard LED?
- Open the docs — look up
Output::new()in the esp-hal GPIO documentation. What parameters does it take? - Change the pin to match your uFerris board
- Flash and verify — the LED should blink
cd examples/blinky
cargo build --release
espflash flash target/riscv32imc-unknown-none-elf/release/blinky --monitor
Watch the LED blink. Notice the blink rate. How is the delay implemented in the code? Can you change it?
Understanding the Code
Before moving on, make sure you can answer:
- What does
Output::new()need? (a pin peripheral, an initial level, a config) - What does
OutputConfig::default()give you? (Look it up in the docs!) - What does
toggle()do? (Flip the pin state: high → low, low → high)
Look at your uFerris pinout card. Find the pin labeled "LED" or with an LED symbol. Replace `peripherals.GPIO0` with `peripherals.GPIOXX` where `XX` is the pin number.
The solution is in `solutions/blinky-adapted/src/main.rs`. But try to figure it out from the pinout card first — that's the whole point!
Done?
If your LED is blinking, you've just applied the Create → Configure → Control pattern for the first time. But we only used OutputConfig::default() — there's a lot more to explore. That's next.