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.

No comments:

Post a Comment