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 e6822c1 commit 0b0ba28Copy full SHA for 0b0ba28
examples/trinket/src/bin/trinket-simple-pwm.rs
@@ -0,0 +1,28 @@
1
+/*!
2
+ * Example of using simple_pwm to fade the built-in LED in and out.
3
+ */
4
+
5
+#![no_std]
6
+#![no_main]
7
8
+use arduino_hal::simple_pwm::*;
9
+use panic_halt as _;
10
11
+#[arduino_hal::entry]
12
+fn main() -> ! {
13
+ let dp = arduino_hal::Peripherals::take().unwrap();
14
+ let pins = arduino_hal::pins!(dp);
15
16
+ let timer0 = Timer0Pwm::new(dp.TC0, Prescaler::Prescale64);
17
18
+ // Digital pin 1 is also connected to an onboard LED marked "L"
19
+ let mut pwm_led = pins.d1.into_output().into_pwm(&timer0);
20
+ pwm_led.enable();
21
22
+ loop {
23
+ for x in (0..=255).chain((0..=254).rev()) {
24
+ pwm_led.set_duty(x);
25
+ arduino_hal::delay_ms(10);
26
+ }
27
28
+}
0 commit comments