diff --git a/content/hardware/06.nicla/boards/nicla-sense-me/tutorials/cheat-sheet/cheat-sheet.md b/content/hardware/06.nicla/boards/nicla-sense-me/tutorials/cheat-sheet/cheat-sheet.md index a3b0c5f125..4828da841e 100644 --- a/content/hardware/06.nicla/boards/nicla-sense-me/tutorials/cheat-sheet/cheat-sheet.md +++ b/content/hardware/06.nicla/boards/nicla-sense-me/tutorials/cheat-sheet/cheat-sheet.md @@ -127,17 +127,13 @@ The Nicla System header is required to use the RGB LED. #include "Nicla_System.h" ``` -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. - -```cpp -using namespace nicla; -``` +Since the functions are scoped under a specific Class name called "nicla", you need to explicitly write it before each statement. The LEDs need to be started along with the Nicla inside `void setup()`: ```arduino -begin(); -leds.begin(); +nicla::begin(); +nicla::leds.begin(); ``` 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,9 +149,9 @@ To set the LED to a predefined color (e.g. green or blue): ```arduino void loop() { - leds.setColor(green); + nicla::leds.setColor(green); delay(1000); - leds.setColor(blue); + nicla::leds.setColor(blue); delay(1000); } ``` @@ -163,7 +159,7 @@ void loop() { To turn the LED off: ```arduino -leds.setColor(off); +nicla::leds.setColor(off); ``` You can also choose a value between 255 - 0 for each color component to set a custom color: @@ -174,13 +170,32 @@ void loop() { int green = 72; int blue = 122; - leds.setColor(red, green, blue); + nicla::leds.setColor(red, green, blue); + delay(1000); + nicla::leds.setColor(off); + delay(1000); +} +``` + +This is a complete example code to blink the built-in I2C LED: + +```arduino +#include "Nicla_System.h" + +void setup() { + nicla::begin(); + nicla::leds.begin(); +} + +void loop() { + nicla::leds.setColor(red); delay(1000); - leds.setColor(off); + nicla::leds.setColor(off); delay(1000); } ``` + ## Sensors There are three ways to read from the on-board sensors: 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