We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f0380a4 commit 36dc214Copy full SHA for 36dc214
examples/arduino-uno/src/bin/uno-simple-pwm.rs
@@ -0,0 +1,27 @@
1
+/*!
2
+ * Example of using simple_pwm to fade a LED in and out on pin d5.
3
+ */
4
+#![no_std]
5
+#![no_main]
6
+
7
+use arduino_hal::simple_pwm::*;
8
+use panic_halt as _;
9
10
+#[arduino_hal::entry]
11
+fn main() -> ! {
12
+ let dp = arduino_hal::Peripherals::take().unwrap();
13
+ let pins = arduino_hal::pins!(dp);
14
15
+ let timer0 = Timer0Pwm::new(dp.TC0, Prescaler::Prescale64);
16
17
+ // Digital pin 5 is connected to a LED and a resistor in series
18
+ let mut pwm_led = pins.d5.into_output().into_pwm(&timer0);
19
+ pwm_led.enable();
20
21
+ loop {
22
+ for x in (0..=255).chain((0..=254).rev()) {
23
+ pwm_led.set_duty(x);
24
+ arduino_hal::delay_ms(10);
25
+ }
26
27
+}
0 commit comments