From 6045406ea17f4c7c51951a29a9eb53bd6ddb449e Mon Sep 17 00:00:00 2001 From: Jet Pham Date: Wed, 1 Oct 2025 23:16:50 -0700 Subject: [PATCH] feat: make LED blink --- README.md | 22 ++++++++++++++++++++++ src/bin/main.rs | 24 +++++++++++++++++++----- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index e012bf1..fb759d6 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,25 @@ On September 30, 2025, a few Noisebridgers got together and started to hack on t

> We used Kirkland Vodka to clean flux after soldering header pins + +## Setup + +This project requires Nix for development. Follow these steps to set up the development environment: + +1. Install Nix if you haven't already: + - Follow the installation instructions at [nixos.org](https://nixos.org/download.html) + +2. Enter the development environment: + ```bash + nix develop + ``` + +## Running + +To run the project: + +```bash +sudo cargo run --release +``` + +**Note:** The `sudo` command is required for accessing the USB serial port on most Linux systems. diff --git a/src/bin/main.rs b/src/bin/main.rs index f38be46..8c68063 100644 --- a/src/bin/main.rs +++ b/src/bin/main.rs @@ -8,8 +8,9 @@ use defmt::info; use esp_hal::clock::CpuClock; +use esp_hal::delay::Delay; +use esp_hal::gpio::{Level, Output, OutputConfig}; use esp_hal::main; -use esp_hal::time::{Duration, Instant}; use esp_hal::timer::timg::TimerGroup; use panic_rtt_target as _; @@ -32,12 +33,25 @@ fn main() -> ! { let timg0 = TimerGroup::new(peripherals.TIMG0); let _init = esp_wifi::init(timg0.timer0, esp_hal::rng::Rng::new(peripherals.RNG)).unwrap(); + + let mut led = Output::new(peripherals.GPIO15, Level::Low, OutputConfig::default()); + + // Initialize delay + let delay = Delay::new(); + + info!("Starting LED blink program on GPIO15..."); loop { - info!("Hello world!"); - let delay_start = Instant::now(); - while delay_start.elapsed() < Duration::from_millis(500) {} + // Turn LED on + led.set_high(); + info!("LED ON"); + delay.delay_millis(1000); + + // Turn LED off + led.set_low(); + info!("LED OFF"); + delay.delay_millis(1000); } - + // for inspiration have a look at the examples at https://github.com/esp-rs/esp-hal/tree/esp-hal-v1.0.0-rc.0/examples/src/bin }