Skip to content

Update RGB LED section on Cheat-sheet #754

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -153,17 +149,17 @@ 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);
}
```

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:
Expand All @@ -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:
Expand Down
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