Exercise C: Alternative Blink

~15 min

Goal

Find a different way to achieve the same blink behavior, without using the same approach as in Exercise A.

Steps

1. Create a New Project

esp-generate --chip esp32c3 -o unstable-hal -o vscode -o esp-backtrace -o log --headless gpio_challenge
cd gpio_challenge

2. Explore the Output Documentation

Go back to the Output struct documentation and scroll through all the methods available on Output.

3. Find an Alternative

The blinky example in Exercise A used one specific approach to switch the LED on and off. Your task: find a different method that achieves the same result.

Hints:

  • There's more than one way to change pin state
  • Some methods combine multiple operations
  • Check both the inherent methods and the trait methods

4. Modify and Test

Update your blinky code to use the alternative approach. The LED should still blink at the same rate.

cargo build --release
espflash flash target/riscv32imc-unknown-none-elf/release/blinky --monitor

What to Notice

  • How many different ways can you find to control an output pin?
  • Which approach results in simpler code?