From 804a2b210938cc65b8dc8df5d1aa26c8f3975ff3 Mon Sep 17 00:00:00 2001 From: Ali Jahangiri <75624145+aliphys@users.noreply.github.com> Date: Thu, 2 Feb 2023 20:32:41 +0100 Subject: [PATCH 1/3] Add Comments and ASCII Art --- .../examples/Blink_Nicla/Blink_Nicla.ino | 62 ++++++++++++++++--- 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/libraries/Nicla_System/examples/Blink_Nicla/Blink_Nicla.ino b/libraries/Nicla_System/examples/Blink_Nicla/Blink_Nicla.ino index a9313f352..71fb0b90f 100644 --- a/libraries/Nicla_System/examples/Blink_Nicla/Blink_Nicla.ino +++ b/libraries/Nicla_System/examples/Blink_Nicla/Blink_Nicla.ino @@ -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); -} \ No newline at end of file + //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 +} + + From 2bb5b8976a427b481541064aab72e96cea4a1344 Mon Sep 17 00:00:00 2001 From: Ali Jahangiri <75624145+aliphys@users.noreply.github.com> Date: Thu, 2 Feb 2023 20:33:06 +0100 Subject: [PATCH 2/3] Add warning for Nicla Vision --- libraries/Nicla_System/examples/Blink_Nicla/Blink_Nicla.ino | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libraries/Nicla_System/examples/Blink_Nicla/Blink_Nicla.ino b/libraries/Nicla_System/examples/Blink_Nicla/Blink_Nicla.ino index 71fb0b90f..4b97dee3c 100644 --- a/libraries/Nicla_System/examples/Blink_Nicla/Blink_Nicla.ino +++ b/libraries/Nicla_System/examples/Blink_Nicla/Blink_Nicla.ino @@ -37,6 +37,11 @@ Last edit: 2nd February 2023 */ +//This sketch is only for the Nicla Sense ME, not the Nicla Vision +#ifdef ARDUINO_NICLA_VISION + #error "Run the standard Blink.ino sketch for the Nicla Vision" + + // Intialise library which communicates with RGB driver // Functions accessible under 'nicla' namespace #include "Nicla_System.h" From c8e5f11d4f77f54267f58c27999b888e81b4115d Mon Sep 17 00:00:00 2001 From: Ali Jahangiri <75624145+aliphys@users.noreply.github.com> Date: Mon, 6 Feb 2023 09:55:16 +0100 Subject: [PATCH 3/3] Update libraries/Nicla_System/examples/Blink_Nicla/Blink_Nicla.ino --- libraries/Nicla_System/examples/Blink_Nicla/Blink_Nicla.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libraries/Nicla_System/examples/Blink_Nicla/Blink_Nicla.ino b/libraries/Nicla_System/examples/Blink_Nicla/Blink_Nicla.ino index 4b97dee3c..a8e2383d6 100644 --- a/libraries/Nicla_System/examples/Blink_Nicla/Blink_Nicla.ino +++ b/libraries/Nicla_System/examples/Blink_Nicla/Blink_Nicla.ino @@ -40,7 +40,7 @@ //This sketch is only for the Nicla Sense ME, not the Nicla Vision #ifdef ARDUINO_NICLA_VISION #error "Run the standard Blink.ino sketch for the Nicla Vision" - +#endif // Intialise library which communicates with RGB driver // Functions accessible under 'nicla' namespace