Skip to content

Commit 481778c

Browse files
authored
Merge pull request #2818 from adafruit/pixel_trinkey_factory
adding factory test for pixel trinkey
2 parents ec15ff3 + a4f069b commit 481778c

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
// SPDX-FileCopyrightText: 2024 ladyada for Adafruit Industries
2+
//
3+
// SPDX-License-Identifier: MIT
4+
5+
#include <Adafruit_DotStar.h>
6+
#include <Adafruit_NeoPixel.h>
7+
8+
#define NUMPIXELS 64
9+
Adafruit_DotStar dotstrip(NUMPIXELS, PIN_DATA, PIN_CLOCK, DOTSTAR_BRG);
10+
Adafruit_NeoPixel neostrip(NUMPIXELS, PIN_DATA, NEO_GRB + NEO_KHZ800);
11+
Adafruit_NeoPixel pixel(1, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800); // internal board pixel
12+
13+
void setup() {
14+
Serial.begin(115200);
15+
16+
dotstrip.begin();
17+
dotstrip.setBrightness(25);
18+
dotstrip.show();
19+
20+
neostrip.begin();
21+
neostrip.setBrightness(25);
22+
neostrip.show();
23+
24+
pixel.begin();
25+
pixel.setBrightness(25);
26+
pixel.show();
27+
}
28+
29+
uint16_t firstPixelHue = 0;
30+
bool which_strip = false;
31+
32+
void loop() {
33+
firstPixelHue += 256;
34+
35+
if (which_strip == true) {
36+
// neopixel
37+
for(int i=0; i<neostrip.numPixels(); i++) {
38+
int pixelHue = firstPixelHue + (i * 65536L / neostrip.numPixels());
39+
neostrip.setPixelColor(i, neostrip.gamma32(neostrip.ColorHSV(pixelHue)));
40+
}
41+
neostrip.show();
42+
} else {
43+
// dotstar
44+
for(int i=0; i<dotstrip.numPixels(); i++) {
45+
int pixelHue = firstPixelHue + (i * 65536L / dotstrip.numPixels());
46+
dotstrip.setPixelColor(i, dotstrip.gamma32(dotstrip.ColorHSV(pixelHue)));
47+
}
48+
dotstrip.show();
49+
}
50+
pixel.setPixelColor(0, pixel.gamma32(pixel.ColorHSV(firstPixelHue)));
51+
pixel.show();
52+
delay(10);
53+
54+
if (firstPixelHue == 0) {
55+
which_strip = !which_strip;
56+
}
57+
58+
float powerVoltage;
59+
powerVoltage = analogRead(A0) / 1023.0 * 3.3;
60+
powerVoltage *= 2; // resistor divider by 2, so * by 2
61+
Serial.print("Power voltage: ");
62+
Serial.print(powerVoltage);
63+
Serial.println(" V");
64+
}

0 commit comments

Comments
 (0)