Go Down

Topic: Testing the onboard square SMD RGB LED module  (Read 276 times) previous topic - next topic


Mar 30, 2019, 11:32 pm Last Edit: Apr 08, 2019, 06:54 pm by kenharpster
I found a code snippet on-line from sandeepmistry and created a simple sketch to see just how the SMD RGB LED module works. I thought it might be useful as an on-board visual status indicator in lieu of using the serial monitor. Has anyone else tried using it for anything? From what I understand, and I could be wrong, it would appear that the LED is not available if you enable BLE.

Here is the code:

// Include the library code
#include <WiFiNINA.h>
#include <utility/wifi_drv.h>

void setup() {
  // Set LED pin modes to output
  WiFiDrv::pinMode(25, OUTPUT);
  WiFiDrv::pinMode(26, OUTPUT);
  WiFiDrv::pinMode(27, OUTPUT);

  // Set all LED color levels to zero for off, the max value is 128
  WiFiDrv::analogWrite(25, 0);    // RED
  WiFiDrv::analogWrite(26, 0);    // GREEN
  WiFiDrv::analogWrite(27, 0);    // BLUE

void loop() {
  // Set Inital test values
  int r = 32;
  int g = 32;
  int b = 32;

  // Loop through each LED one at a time (Red, Green, Blue)
  WiFiDrv::analogWrite(25, r);
  WiFiDrv::analogWrite(25, 0);
  WiFiDrv::analogWrite(26, g); 
  WiFiDrv::analogWrite(26, 0);
  WiFiDrv::analogWrite(27, b); 
  WiFiDrv::analogWrite(27, 0); 

Go Up