Skip to content

Commit ec93fdf

Browse files
authored
Merge pull request #754 from mcmchris/patch-1
Update RGB LED section on Cheat-sheet
2 parents 100aeff + 346e23a commit ec93fdf

File tree

1 file changed

+27
-12
lines changed
  • content/hardware/06.nicla/boards/nicla-sense-me/tutorials/cheat-sheet

1 file changed

+27
-12
lines changed

content/hardware/06.nicla/boards/nicla-sense-me/tutorials/cheat-sheet/cheat-sheet.md

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -127,17 +127,13 @@ The Nicla System header is required to use the RGB LED.
127127
#include "Nicla_System.h"
128128
```
129129

130-
Since the functions are scoped under a specific name called "nicla", you can use the following statement to have convenient access without repeating explicitly the namespace before every function call.
131-
132-
```cpp
133-
using namespace nicla;
134-
```
130+
Since the functions are scoped under a specific Class name called "nicla", you need to explicitly write it before each statement.
135131

136132
The LEDs need to be started along with the Nicla inside `void setup()`:
137133

138134
```arduino
139-
begin();
140-
leds.begin();
135+
nicla::begin();
136+
nicla::leds.begin();
141137
```
142138

143139
The LED can be set to the desired RGB value using red, green and blue components or by using one of the following predefined colors:
@@ -153,17 +149,17 @@ To set the LED to a predefined color (e.g. green or blue):
153149

154150
```arduino
155151
void loop() {
156-
leds.setColor(green);
152+
nicla::leds.setColor(green);
157153
delay(1000);
158-
leds.setColor(blue);
154+
nicla::leds.setColor(blue);
159155
delay(1000);
160156
}
161157
```
162158

163159
To turn the LED off:
164160

165161
```arduino
166-
leds.setColor(off);
162+
nicla::leds.setColor(off);
167163
```
168164

169165
You can also choose a value between 255 - 0 for each color component to set a custom color:
@@ -174,13 +170,32 @@ void loop() {
174170
int green = 72;
175171
int blue = 122;
176172
177-
leds.setColor(red, green, blue);
173+
nicla::leds.setColor(red, green, blue);
174+
delay(1000);
175+
nicla::leds.setColor(off);
176+
delay(1000);
177+
}
178+
```
179+
180+
This is a complete example code to blink the built-in I2C LED:
181+
182+
```arduino
183+
#include "Nicla_System.h"
184+
185+
void setup() {
186+
nicla::begin();
187+
nicla::leds.begin();
188+
}
189+
190+
void loop() {
191+
nicla::leds.setColor(red);
178192
delay(1000);
179-
leds.setColor(off);
193+
nicla::leds.setColor(off);
180194
delay(1000);
181195
}
182196
```
183197

198+
184199
## Sensors
185200

186201
There are three ways to read from the on-board sensors:

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy