File tree Expand file tree Collapse file tree 4 files changed +66
-0
lines changed Expand file tree Collapse file tree 4 files changed +66
-0
lines changed Original file line number Diff line number Diff line change
1
+ # SPDX-License-Identifier: Apache-2.0
2
+
3
+ cmake_minimum_required (VERSION 3.20.0 )
4
+
5
+ set (DTC_OVERLAY_FILE $ENV{ZEPHYR_BASE} /../modules/lib/Arduino-Zephyr-API/variants/${BOARD}/${BOARD}.overlay )
6
+
7
+ find_package (Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE} )
8
+ project (fade )
9
+
10
+ target_sources (app PRIVATE src/app.cpp )
11
+
12
+ zephyr_compile_options (-Wno-unused-variable -Wno-comment )
Original file line number Diff line number Diff line change
1
+ .. _fade :
2
+
3
+ Fade
4
+ ####
5
+
6
+ Overview
7
+ ********
8
+
9
+ The Fade sample gradually increases/decreases the voltage of the output pin.
10
+ When connecting the LED to the output pin, the LED blinks gradually.
11
+
12
+ Building and Running
13
+ ********************
14
+
15
+ Build and flash Fade sample as follows,
16
+
17
+ ```sh
18
+ $> west build -p -b arduino_nano_33_ble samples/basic/fade/ -DZEPHYR_EXTRA_MODULES=/home/$USER/zephyrproject/modules/lib/Arduino-Core-Zephyr
19
+
20
+ $> west flash --bossac=/home/$USER/.arduino15/packages/arduino/tools/bossac/1.9.1-arduino2/bossac
21
+ ` ``
Original file line number Diff line number Diff line change
1
+ CONFIG_ARDUINO_API=y
2
+ CONFIG_PWM=y
Original file line number Diff line number Diff line change
1
+ /*
2
+ * Copyright (c) 2022 TOKITA Hiroshi <tokita.hiroshi@fujitsu.com>
3
+ *
4
+ * SPDX-License-Identifier: Apache-2.0
5
+ */
6
+
7
+ #include < Arduino.h>
8
+
9
+ const int led = 3 ; // PWM output pin.
10
+ const int increments = 5 ;
11
+ const int wait_ms = 10 ;
12
+
13
+ void setup () {
14
+ /* Pin that use as the PWM output must not configure by pinMode() */
15
+ }
16
+
17
+ void loop () {
18
+ int value = 0 ;
19
+ while (value < 256 ) {
20
+ analogWrite (led, value);
21
+ value += increments;
22
+ delay (wait_ms);
23
+ }
24
+
25
+ value = 255 ;
26
+ while (value >= 0 ) {
27
+ analogWrite (led, value);
28
+ value -= increments;
29
+ delay (wait_ms);
30
+ }
31
+ }
You can’t perform that action at this time.
0 commit comments