neopixel trinkey examples
Adding basic examples for NeoPixel Trinkey guide
This commit is contained in:
parent
21123b6011
commit
0997d95c9e
6 changed files with 162 additions and 0 deletions
|
|
@ -0,0 +1,32 @@
|
|||
// SPDX-FileCopyrightText: 2024 ladyada for Adafruit Industries
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
|
||||
Adafruit_NeoPixel pixel(1, PIN_NEOPIXEL, NEO_GRB + NEO_KHZ800);
|
||||
|
||||
const int buttonPin = MISO;
|
||||
|
||||
int buttonState = 0;
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
pinMode(buttonPin, INPUT);
|
||||
pixel.begin();
|
||||
pixel.setBrightness(10);
|
||||
pixel.show();
|
||||
}
|
||||
|
||||
void loop() {
|
||||
buttonState = digitalRead(buttonPin);
|
||||
|
||||
if (buttonState == HIGH) {
|
||||
pixel.setPixelColor(0, 0x0);
|
||||
pixel.show();
|
||||
} else {
|
||||
pixel.setPixelColor(0, 0xFF0000);
|
||||
pixel.show();
|
||||
}
|
||||
delay(100);
|
||||
}
|
||||
31
Neo_Trinkey_Examples/Arduino_DotStar/Arduino_DotStar.ino
Normal file
31
Neo_Trinkey_Examples/Arduino_DotStar/Arduino_DotStar.ino
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// SPDX-FileCopyrightText: 2024 ladyada for Adafruit Industries
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <Adafruit_DotStar.h>
|
||||
|
||||
#define NUMPIXELS 30
|
||||
Adafruit_DotStar dotstrip(NUMPIXELS, PIN_DATA, PIN_CLOCK, DOTSTAR_BRG);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
dotstrip.begin();
|
||||
dotstrip.setBrightness(25);
|
||||
dotstrip.show();
|
||||
|
||||
}
|
||||
|
||||
uint16_t firstPixelHue = 0;
|
||||
|
||||
void loop() {
|
||||
firstPixelHue += 256;
|
||||
|
||||
for(int i=0; i<dotstrip.numPixels(); i++) {
|
||||
int pixelHue = firstPixelHue + (i * 65536L / dotstrip.numPixels());
|
||||
dotstrip.setPixelColor(i, dotstrip.gamma32(dotstrip.ColorHSV(pixelHue)));
|
||||
}
|
||||
dotstrip.show();
|
||||
delay(10);
|
||||
|
||||
}
|
||||
31
Neo_Trinkey_Examples/Arduino_NeoPixel/Arduino_NeoPixel.ino
Normal file
31
Neo_Trinkey_Examples/Arduino_NeoPixel/Arduino_NeoPixel.ino
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// SPDX-FileCopyrightText: 2024 ladyada for Adafruit Industries
|
||||
//
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
#include <Adafruit_NeoPixel.h>
|
||||
|
||||
#define NUMPIXELS 30
|
||||
Adafruit_NeoPixel neostrip(NUMPIXELS, PIN_DATA, NEO_GRB + NEO_KHZ800);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
|
||||
neostrip.begin();
|
||||
neostrip.setBrightness(25);
|
||||
neostrip.show();
|
||||
|
||||
}
|
||||
|
||||
uint16_t firstPixelHue = 0;
|
||||
|
||||
void loop() {
|
||||
firstPixelHue += 256;
|
||||
for(int i=0; i<neostrip.numPixels(); i++) {
|
||||
int pixelHue = firstPixelHue + (i * 65536L / neostrip.numPixels());
|
||||
neostrip.setPixelColor(i, neostrip.gamma32(neostrip.ColorHSV(pixelHue)));
|
||||
}
|
||||
neostrip.show();
|
||||
|
||||
delay(10);
|
||||
|
||||
}
|
||||
20
Neo_Trinkey_Examples/CircuitPython_Digital_Input/code.py
Normal file
20
Neo_Trinkey_Examples/CircuitPython_Digital_Input/code.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
|
||||
# SPDX-License-Identifier: MIT
|
||||
"""CircuitPython Digital Input example
|
||||
Blinking a built-in NeoPixel LED using a button switch.
|
||||
|
||||
"""
|
||||
import board
|
||||
import digitalio
|
||||
import neopixel
|
||||
|
||||
pixel = neopixel.NeoPixel(board.NEOPIXEL, 1)
|
||||
|
||||
button = digitalio.DigitalInOut(board.D4)
|
||||
button.switch_to_input(pull=digitalio.Pull.UP)
|
||||
|
||||
while True:
|
||||
if not button.value:
|
||||
pixel.fill((255, 0, 0))
|
||||
else:
|
||||
pixel.fill((0, 0, 0))
|
||||
25
Neo_Trinkey_Examples/CircuitPython_DotStar/code.py
Normal file
25
Neo_Trinkey_Examples/CircuitPython_DotStar/code.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# SPDX-FileCopyrightText: 2024 Liz Clark for Adafruit Industries
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
import time
|
||||
import board
|
||||
from rainbowio import colorwheel
|
||||
import adafruit_dotstar as dotstar
|
||||
|
||||
clock_pin = board.CLOCK
|
||||
data_pin = board.DATA
|
||||
num_dots = 30
|
||||
speed = 0.01
|
||||
brightness = 0.2
|
||||
order = "PGBR" # PGBR, PGRB, PRBG or PRGB
|
||||
dots = dotstar.DotStar(clock_pin, data_pin, num_dots,
|
||||
brightness=brightness, auto_write=True,
|
||||
pixel_order=order)
|
||||
|
||||
hue = 0
|
||||
dots.fill(colorwheel(hue))
|
||||
|
||||
while True:
|
||||
hue = (hue + 1) % 256
|
||||
dots.fill(colorwheel(hue))
|
||||
time.sleep(speed)
|
||||
23
Neo_Trinkey_Examples/CircuitPython_NeoPixel/code.py
Normal file
23
Neo_Trinkey_Examples/CircuitPython_NeoPixel/code.py
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
# SPDX-FileCopyrightText: 2024 Liz Clark for Adafruit Industries
|
||||
# SPDX-License-Identifier: MIT
|
||||
|
||||
import time
|
||||
import board
|
||||
from rainbowio import colorwheel
|
||||
import neopixel
|
||||
|
||||
pixel_pin = board.DATA
|
||||
num_pixels = 30
|
||||
speed = 0.01
|
||||
brightness = 0.5
|
||||
order = "GRB" # "GRBW" for RGBW NeoPixels
|
||||
pixels = neopixel.NeoPixel(pixel_pin, num_pixels,
|
||||
brightness=brightness, auto_write=True,
|
||||
pixel_order=order)
|
||||
hue = 0
|
||||
pixels.fill(colorwheel(hue))
|
||||
|
||||
while True:
|
||||
hue = (hue + 1) % 256
|
||||
pixels.fill(colorwheel(hue))
|
||||
time.sleep(speed)
|
||||
Loading…
Reference in a new issue