Errata in BLE Sense Rev 2 Tutorial RGB Pixel Control

This tutorial has an error in RGB pixel control:
docs.arduino.cc/tutorials/nano-33-ble-sense-rev2/cheat-sheet

The tutorial has:
image

But this code running on my BLE Sense Rev 2 shows that logic LOW turns ON the LED pixels.

void setup() {
  // no setup required
}

void loop() {
  // turn all LED pixels ON
  digitalWrite(LEDR, LOW); //RED
  digitalWrite(LEDG, LOW); //GREEN
  digitalWrite(LEDB, LOW); //BLUE
  while(1);
}

Also, while not an errata, when using analogWrite, a 255 value turns a pixel OFF and a 0 value turns a pixel ON. Not an error in the tutorial, just counter-intuitive.

image

You should define the pin to which each color of the RGB LED is connected...

#define LEDRpin 2
#define LEDGpin 3
#define LEDBpin 4

Then declare each pin as OUTPUT...

  pinMode(LEDRpin, OUTPUT);
  pinMode(LEDGpin, OUTPUT);
  pinMode(LEDBpin, OUTPUT);

So, in your code, try this... if LOW does not enable your RGBLED, try HIGH... it will depend on the RGBLED common leg.

#define LEDRpin 2
#define LEDGpin 3
#define LEDBpin 4

void setup() {
  pinMode(LEDRpin, OUTPUT);
  pinMode(LEDGpin, OUTPUT);
  pinMode(LEDBpin, OUTPUT);
}

void loop() {
  // turn all LED pixels ON
  digitalWrite(LEDR, LOW); //RED
  digitalWrite(LEDG, LOW); //GREEN
  digitalWrite(LEDB, LOW); //BLUE
  while(1);
}

That is nothing to do with the code and everything to do with how your LEDs are wired up.

So shows us a schematic of what you have and maybe we could tell you where you are misunderstanding things.

Thanks for the quick response. Your code performs the same as mine in turning all 3 pixels on.

My point in posting this is that the tutorial is in error in stating the that digitalWrite(LEDR, HIGH); turns the LED pixel on. Rather it is digitalWrite(LEDR, LOW); which turns the pixel on. The logic is inverted relative to the text.

The schematic is the standard, unaltered, BLE Sense Rev 2 board. The LED pixels are on the board. The tutorial is for the BLE Sense Rev 2 board. The point in posting is that the tutorial has a logic error.

I expected the posted code snippet in the tutorial for the BLE Sense Rev 2 board to work as stated. I did not expect the logic error. Hence I was sharing this observation.

And I expected you to cooperate by actually supplying the schematic, not what you answered.

My apologies. I will have to go find the BLE Sense Rev 2 schematic on line.

Yes... noted in my comment above...

Please, my objective here is to communicate what I believe is an error in a tutorial. I am doing this so that others who may be perplexed by why the code snippet is not working as expected have some additional information.

I have every expectation that once I find the Rev 2 schematic the fact that the pixels are ON when a logic LOW is written will make sense. That understanding does not address what looks to be an error in the tutorial.

1 Like

Ok, but the RGBLED are "onboard" to the Arduino Nano 33 BLE Sense 2.

Nano 33 BLE Sense Rev 2-schematics.pdf (1.4 MB)
Here is the BLE Sense Rev 2 schematic. Thank you for your patience.

1 Like

I see from the schematic that the common leg is +3V3 for DL3.
So that's the technical reason why a logic LOW turns on the pixels.

I apologize for not not clearly stating my intent in this posting which was to correct the tutorial which states that a logic HIGH turns on the pixels.
Now the reason for this situation is explained.
Thank you all for your help.

Oh... sorry. Now I understand.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.