LED blinking is working properly well

This commit is contained in:
Filipriec
2025-10-13 10:56:26 +02:00
parent 75f038262b
commit 4e9566678a

View File

@@ -49,7 +49,7 @@ async fn main(spawner: Spawner) {
frequency: Rate::from_khz(24), frequency: Rate::from_khz(24),
}).unwrap(); }).unwrap();
let led = peripherals.GPIO2; let led = peripherals.GPIO4;
let mut channel0 = ledc.channel(channel::Number::Channel0, led); let mut channel0 = ledc.channel(channel::Number::Channel0, led);
channel0.configure(channel::config::Config { channel0.configure(channel::config::Config {
timer: &lstimer0, timer: &lstimer0,
@@ -58,12 +58,18 @@ async fn main(spawner: Spawner) {
}).unwrap(); }).unwrap();
loop { loop {
channel0.start_duty_fade(0, 100, 1000).unwrap(); // channel0.start_duty_fade(0, 100, 1000).unwrap();
while channel0.is_duty_fade_running() {} // while channel0.is_duty_fade_running() {}
channel0.start_duty_fade(100, 0, 1000).unwrap(); // channel0.start_duty_fade(100, 0, 1000).unwrap();
while channel0.is_duty_fade_running() {} // while channel0.is_duty_fade_running() {}
Timer::after(Duration::from_millis(30)).await; channel0.set_duty(100).unwrap();
info!("LED ON");
Timer::after(Duration::from_secs(1)).await;
channel0.set_duty(0).unwrap();
info!("LED OFF");
Timer::after(Duration::from_secs(1)).await;
} }
// 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 // 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