Skip to content

Commit 1b22237

Browse files
committed
update webusb example to support NEOPIXEL_POWER pin
1 parent 7c20752 commit 1b22237

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

examples/WebUSB/webusb_rgb/webusb_rgb.ino

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,20 @@
3131
// Which pin on the Arduino is connected to the NeoPixels?
3232
// On a Trinket or Gemma we suggest changing this to 1
3333
// use on-board neopixel PIN_NEOPIXEL if existed
34-
#ifdef PIN_NEOPIXEL
35-
#define PIN PIN_NEOPIXEL
36-
#else
37-
#define PIN 8
34+
#ifndef PIN_NEOPIXEL
35+
#define PIN_NEOPIXEL 8
3836
#endif
3937

4038
// How many NeoPixels are attached to the Arduino?
41-
#define NUMPIXELS 10
39+
// use on-board defined NEOPIXEL_NUM if existed
40+
#ifndef NEOPIXEL_NUM
41+
#define NEOPIXEL_NUM 10
42+
#endif
4243

4344
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
4445
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
4546
// example for more information on possible values.
46-
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
47+
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NEOPIXEL_NUM, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800);
4748

4849
// USB WebUSB object
4950
Adafruit_USBD_WebUSB usb_web;
@@ -62,6 +63,11 @@ void setup()
6263
Serial.begin(115200);
6364

6465
// This initializes the NeoPixel with RED
66+
#ifdef NEOPIXEL_POWER
67+
pinMode(NEOPIXEL_POWER, OUTPUT);
68+
digitalWrite(NEOPIXEL_POWER, NEOPIXEL_POWER_ON);
69+
#endif
70+
6571
pixels.begin();
6672
pixels.setBrightness(50);
6773
pixels.fill(0xff0000);

0 commit comments

Comments
 (0)