Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add Comments and ASCII Art
  • Loading branch information
aliphys authored Feb 2, 2023
commit 804a2b210938cc65b8dc8df5d1aa26c8f3975ff3
62 changes: 54 additions & 8 deletions libraries/Nicla_System/examples/Blink_Nicla/Blink_Nicla.ino
Original file line number Diff line number Diff line change
@@ -1,13 +1,59 @@
#include "Nicla_System.h"
/*
Blink for Nicla Sense ME

Turns green LED on for one second, then turn it off.

Most Arduino boards have a single LED connected from D13 to ground
(with a current limiting resistor). In the Nicla Sense ME, the common
anode RGB LED (DL1) is controlled by a RGB LED Driver (U8).
The RGB LED Driver state is set via I2C by the ANNA-B112 Module (MD1).

┌────────────┐ ┌────────────┐
│ ANNA-B112 │ │ RGB-Driver │ VPMID
│ MD-1 │ │ U8 │ Red ─┬─
│ │ │ OUT3├────────◄──────┐ │
│ │ I2C │ │ Green│ │
│ ├──────┤ OUT2├────────◄──────┼───┘
│ │ │ │ Blue │
│ │ │ OUT1├────────◄──────┘
│ │ │ │
│ │ │ │
│ │ │ │
└────────────┘ └────────┬───┘

All of this is abstracted via the Nicla_System.h header file. Details
on use for controling RGB LED can be found at:
https://docs.arduino.cc/tutorials/nicla-sense-me/cheat-sheet#rgb-led

More advanced users can look at the source code at:
https://github.com/arduino/ArduinoCore-mbed/blob/master/libraries/Nicla_System/src/Nicla_System.h

Authors: Giulia Cioffi, Martino Facchin & Ali Jahangiri

This example code is in the public domain.

Last edit: 2nd February 2023
*/

// Intialise library which communicates with RGB driver
// Functions accessible under 'nicla' namespace
#include "Nicla_System.h"


void setup() {
nicla::begin();
nicla::leds.begin();
//run this code once when Nicla Sense ME board turns on
nicla::begin(); // initialise library
nicla::leds.begin(); // Start I2C connection
}

void loop() {
nicla::leds.setColor(green);
delay(1000);
nicla::leds.setColor(off);
delay(1000);
}
//run this code in a loop
nicla::leds.setColor(green); //turn green LED on
delay(1000); //wait 1 second
nicla::leds.setColor(off); //turn all LEDs off
delay(1000); //wait 1 second
}