File tree Expand file tree Collapse file tree 1 file changed +6
-5
lines changed
examples/WebUSB/webusb_rgb Expand file tree Collapse file tree 1 file changed +6
-5
lines changed Original file line number Diff line number Diff line change 3838#endif
3939
4040// How many NeoPixels are attached to the Arduino?
41- #define NUMPIXELS 1
41+ #define NUMPIXELS 10
4242
4343// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
4444// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
@@ -63,7 +63,7 @@ void setup()
6363 // This initializes the NeoPixel with RED
6464 pixels.begin ();
6565 pixels.setBrightness (50 );
66- pixels.setPixelColor ( 0 , 0xff0000 );
66+ pixels.fill ( 0xff0000 );
6767 pixels.show ();
6868
6969 // wait until device mounted
@@ -95,14 +95,15 @@ void loop()
9595 uint8_t red = 16 *char2num (input[1 ]) + char2num (input[2 ]);
9696 uint8_t green = 16 *char2num (input[3 ]) + char2num (input[4 ]);
9797 uint8_t blue = 16 *char2num (input[5 ]) + char2num (input[6 ]);
98-
99- pixels.setPixelColor (0 , red, green, blue);
98+
99+ uint32_t color = (red << 16 ) | (green << 8 ) | blue;
100+ pixels.fill (color);
100101 pixels.show ();
101102}
102103
103104void line_state_callback (bool connected)
104105{
105106 // connected = green, disconnected = red
106- pixels.setPixelColor ( 0 , connected ? 0x00ff00 : 0xff0000 );
107+ pixels.fill ( connected ? 0x00ff00 : 0xff0000 );
107108 pixels.show ();
108109}
You can’t perform that action at this time.
0 commit comments