Skip to content

Commit 024cb08

Browse files
authored
Merge pull request #2824 from adafruit/neo_trinkey
neopixel trinkey examples
2 parents 3c410fd + 0997d95 commit 024cb08

File tree

6 files changed

+162
-0
lines changed

6 files changed

+162
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// SPDX-FileCopyrightText: 2024 ladyada for Adafruit Industries
2+
//
3+
// SPDX-License-Identifier: MIT
4+
5+
#include <Adafruit_NeoPixel.h>
6+
7+
Adafruit_NeoPixel pixel(1, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800);
8+
9+
const int buttonPin = MISO;
10+
11+
int buttonState = 0;
12+
13+
void setup() {
14+
Serial.begin(115200);
15+
pinMode(buttonPin, INPUT);
16+
pixel.begin();
17+
pixel.setBrightness(10);
18+
pixel.show();
19+
}
20+
21+
void loop() {
22+
buttonState = digitalRead(buttonPin);
23+
24+
if (buttonState == HIGH) {
25+
pixel.setPixelColor(0, 0x0);
26+
pixel.show();
27+
} else {
28+
pixel.setPixelColor(0, 0xFF0000);
29+
pixel.show();
30+
}
31+
delay(100);
32+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// SPDX-FileCopyrightText: 2024 ladyada for Adafruit Industries
2+
//
3+
// SPDX-License-Identifier: MIT
4+
5+
#include <Adafruit_DotStar.h>
6+
7+
#define NUMPIXELS 30
8+
Adafruit_DotStar dotstrip(NUMPIXELS, PIN_DATA, PIN_CLOCK, DOTSTAR_BRG);
9+
10+
void setup() {
11+
Serial.begin(115200);
12+
13+
dotstrip.begin();
14+
dotstrip.setBrightness(25);
15+
dotstrip.show();
16+
17+
}
18+
19+
uint16_t firstPixelHue = 0;
20+
21+
void loop() {
22+
firstPixelHue += 256;
23+
24+
for(int i=0; i<dotstrip.numPixels(); i++) {
25+
int pixelHue = firstPixelHue + (i * 65536L / dotstrip.numPixels());
26+
dotstrip.setPixelColor(i, dotstrip.gamma32(dotstrip.ColorHSV(pixelHue)));
27+
}
28+
dotstrip.show();
29+
delay(10);
30+
31+
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// SPDX-FileCopyrightText: 2024 ladyada for Adafruit Industries
2+
//
3+
// SPDX-License-Identifier: MIT
4+
5+
#include <Adafruit_NeoPixel.h>
6+
7+
#define NUMPIXELS 30
8+
Adafruit_NeoPixel neostrip(NUMPIXELS, PIN_DATA, NEO_GRB + NEO_KHZ800);
9+
10+
void setup() {
11+
Serial.begin(115200);
12+
13+
neostrip.begin();
14+
neostrip.setBrightness(25);
15+
neostrip.show();
16+
17+
}
18+
19+
uint16_t firstPixelHue = 0;
20+
21+
void loop() {
22+
firstPixelHue += 256;
23+
for(int i=0; i<neostrip.numPixels(); i++) {
24+
int pixelHue = firstPixelHue + (i * 65536L / neostrip.numPixels());
25+
neostrip.setPixelColor(i, neostrip.gamma32(neostrip.ColorHSV(pixelHue)));
26+
}
27+
neostrip.show();
28+
29+
delay(10);
30+
31+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
"""CircuitPython Digital Input example
4+
Blinking a built-in NeoPixel LED using a button switch.
5+
6+
"""
7+
import board
8+
import digitalio
9+
import neopixel
10+
11+
pixel = neopixel.NeoPixel(board.NEOPIXEL, 1)
12+
13+
button = digitalio.DigitalInOut(board.D4)
14+
button.switch_to_input(pull=digitalio.Pull.UP)
15+
16+
while True:
17+
if not button.value:
18+
pixel.fill((255, 0, 0))
19+
else:
20+
pixel.fill((0, 0, 0))
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# SPDX-FileCopyrightText: 2024 Liz Clark for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
4+
import time
5+
import board
6+
from rainbowio import colorwheel
7+
import adafruit_dotstar as dotstar
8+
9+
clock_pin = board.CLOCK
10+
data_pin = board.DATA
11+
num_dots = 30
12+
speed = 0.01
13+
brightness = 0.2
14+
order = "PGBR" # PGBR, PGRB, PRBG or PRGB
15+
dots = dotstar.DotStar(clock_pin, data_pin, num_dots,
16+
brightness=brightness, auto_write=True,
17+
pixel_order=order)
18+
19+
hue = 0
20+
dots.fill(colorwheel(hue))
21+
22+
while True:
23+
hue = (hue + 1) % 256
24+
dots.fill(colorwheel(hue))
25+
time.sleep(speed)
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# SPDX-FileCopyrightText: 2024 Liz Clark for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
4+
import time
5+
import board
6+
from rainbowio import colorwheel
7+
import neopixel
8+
9+
pixel_pin = board.DATA
10+
num_pixels = 30
11+
speed = 0.01
12+
brightness = 0.5
13+
order = "GRB" # "GRBW" for RGBW NeoPixels
14+
pixels = neopixel.NeoPixel(pixel_pin, num_pixels,
15+
brightness=brightness, auto_write=True,
16+
pixel_order=order)
17+
hue = 0
18+
pixels.fill(colorwheel(hue))
19+
20+
while True:
21+
hue = (hue + 1) % 256
22+
pixels.fill(colorwheel(hue))
23+
time.sleep(speed)

0 commit comments

Comments
 (0)