Friday, June 11, 2021

Arduino Nano RP2040 Connect exercise: control onboard RGB LED

The Nano RP2040 Connect onboard RGB LED is connected through the W-102 module, so the WiFiNINA library needs to be installed and included in sketch.

Exercise to control onboard RGB LED.

#include <WiFiNINA.h>

void setup() {

  delay(2000);

  Serial.begin(9600);
  Serial.println(LEDR);
  Serial.println(LEDG);
  Serial.println(LEDB);
  
  pinMode(LEDR, OUTPUT);
  pinMode(LEDG, OUTPUT);
  pinMode(LEDB, OUTPUT);

  digitalWrite(LEDR, HIGH); //RED
  digitalWrite(LEDG, HIGH); //GREEN
  digitalWrite(LEDB, HIGH); //BLUE

}

void loop() {
  delay(1000);
  digitalWrite(LEDR, LOW); //RED
  digitalWrite(LEDG, LOW); //GREEN
  digitalWrite(LEDB, LOW); //BLUE

  delay(1000);
  digitalWrite(LEDR, HIGH); //RED
  digitalWrite(LEDG, LOW); //GREEN
  digitalWrite(LEDB, LOW); //BLUE


  delay(1000);
  digitalWrite(LEDR, LOW); //RED
  digitalWrite(LEDG, HIGH); //GREEN
  digitalWrite(LEDB, LOW); //BLUE

  delay(1000);
  digitalWrite(LEDR, LOW); //RED
  digitalWrite(LEDG, LOW); //GREEN
  digitalWrite(LEDB, HIGH); //BLUE
}


update@20211-06-28:

After WiFiNINA library updated, the code Serial.println(LEDR) (also LEDG and LEDB) throw error of :

error: call to 'NinaPin::operator int' declared with attribute error: Change me to a #define Serial.println(LEDR);

Just comment the codes to make it work.

Thursday, June 10, 2021

Arduino Nano RP2040 Connect example: read onboard LSM6DSOX IMU module (accelerometer and gyroscope)

Examples to read Nano RP2040 Connect onboard LSM6DSOX IMU module (accelerometer and gyroscope), in Arduino framework.

Install LSM6DSOX library:

- Open Library Manager in Arduino IDE:
Click on Menu Sketch > Include Library > Manager Libraries...

- Search and install Arduino_LSM6DSOX library.


LSM6DSOX examples:

Now you can try LSM6DSOX examples to read accelerometer and gyroscope data from Nano RP2040 Connect onboard LSM6DSOX IMU module.


with graphical view using Menu > Tools > Serial Plotter.

SimpleAccelerometer

SimpleGyroscope




Wednesday, June 9, 2021

Arduino Nano RP2040 Connect

Just receive Arduino Nano RP2040 Connect:





Install Nano RP2040 Connect to Arduino IDE and fix "An error occurred while uploading the sketch":
 

Install Arduino Nano RP2040 Connect board to Arduino IDE.

- Open Board Manager in Arduino IDE.
- Search and install Arduino Mbed OS Nano Boards by Arduino. It's version 2.1.0 currently.


- Once installed, Arduino Mbed OS Nano Boards > Arduino Nano RP2040 Connect will available in board selection list.

If you have XIAO BLE Sense also, check Remark on "Arduino Nano RP2040 Connect" of "Arduino Mbed OS Boards" vs "Arduino Mbed OS Nano Boards".


Fix "An error occurred while uploading the sketch".

In my case on Raspberry Pi, sketch cannot be uploaded; with "An error occurred while uploading the sketch".

To fix it:
- Switch to mbed_rp2040 installed folder:
/home/pi/.arduino15/packages/arduino/hardware/mbed_rp2040/2.1.0
- Run post_install.sh:
$ sudo ./post_install.sh

- Then, you can upload the sketch again.


More exercise:
read onboard LSM6DSOX IMU module (accelerometer and gyroscope)