Skip to content

Commit 2a10dff

Browse files
authored
Merge pull request #2520 from adafruit/neodriver_seesaw
adding NeoDriver seesaw examples
2 parents 2fb8574 + b5f0d01 commit 2a10dff

File tree

4 files changed

+132
-0
lines changed

4 files changed

+132
-0
lines changed

NeoDriver_seesaw_Examples/Arduino_NeoDriver_strandtest/.feather_rp2040.test.only

Whitespace-only changes.
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// SPDX-FileCopyrightText: 2023 Phil B. for Adafruit Industries
2+
// SPDX-License-Identifier: MIT
3+
4+
#include <seesaw_neopixel.h>
5+
#define PIN 15
6+
7+
// Parameter 1 = number of pixels in strip
8+
// Parameter 2 = Arduino pin number (most are valid)
9+
// Parameter 3 = pixel type flags, add together as needed:
10+
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
11+
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
12+
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
13+
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
14+
// NEO_RGBW Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
15+
seesaw_NeoPixel strip = seesaw_NeoPixel(12, PIN, NEO_GRB + NEO_KHZ800);
16+
17+
// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
18+
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
19+
// and minimize distance between Arduino and first pixel. Avoid connecting
20+
// on a live circuit...if you must, connect GND first.
21+
22+
void setup() {
23+
Serial.begin(115200);
24+
25+
while (!Serial) delay(10); // wait until serial port is opened
26+
27+
if(!strip.begin(0x60)){
28+
Serial.println("seesaw not found!");
29+
while(1) delay(10);
30+
}
31+
32+
Serial.println(F("seesaw started OK!"));
33+
34+
strip.show(); // Initialize all pixels to 'off'
35+
}
36+
37+
void loop() {
38+
rainbowCycle(20);
39+
40+
}
41+
42+
void rainbow(uint8_t wait) {
43+
uint16_t i, j;
44+
45+
for(j=0; j<256; j++) {
46+
for(i=0; i<strip.numPixels(); i++) {
47+
strip.setPixelColor(i, Wheel((i+j) & 255));
48+
}
49+
strip.show();
50+
delay(wait);
51+
}
52+
}
53+
54+
// Slightly different, this makes the rainbow equally distributed throughout
55+
void rainbowCycle(uint8_t wait) {
56+
uint16_t i, j;
57+
58+
for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
59+
for(i=0; i< strip.numPixels(); i++) {
60+
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
61+
}
62+
strip.show();
63+
delay(wait);
64+
}
65+
}
66+
67+
// Input a value 0 to 255 to get a color value.
68+
// The colours are a transition r - g - b - back to r.
69+
uint32_t Wheel(byte WheelPos) {
70+
WheelPos = 255 - WheelPos;
71+
if(WheelPos < 85) {
72+
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
73+
}
74+
if(WheelPos < 170) {
75+
WheelPos -= 85;
76+
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
77+
}
78+
WheelPos -= 170;
79+
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
80+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# SPDX-FileCopyrightText: 2023 Liz Clark for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
4+
import time
5+
import board
6+
import busio
7+
from rainbowio import colorwheel
8+
from adafruit_seesaw import seesaw, neopixel
9+
10+
i2c = busio.I2C(board.SCL, board.SDA)
11+
ss = seesaw.Seesaw(i2c, addr=0x60)
12+
neo_pin = 15
13+
num_pixels = 64
14+
15+
pixels = neopixel.NeoPixel(ss, neo_pin, num_pixels, brightness = 0.1)
16+
17+
color_offset = 0
18+
19+
while True:
20+
for i in range(num_pixels):
21+
rc_index = (i * 256 // num_pixels) + color_offset
22+
pixels[i] = colorwheel(rc_index & 255)
23+
pixels.show()
24+
color_offset += 1
25+
time.sleep(0.01)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SPDX-FileCopyrightText: 2023 Liz Clark for Adafruit Industries
2+
# SPDX-License-Identifier: MIT
3+
4+
'''This example should only be used with Linux single board computers
5+
that require creating an I2C busio object by passing in the Bus ID'''
6+
7+
import time
8+
from rainbowio import colorwheel
9+
from adafruit_extended_bus import ExtendedI2C as I2C
10+
from adafruit_seesaw import seesaw, neopixel
11+
12+
i2c = I2C(1)
13+
ss = seesaw.Seesaw(i2c, addr=0x60)
14+
neo_pin = 15
15+
num_pixels = 64
16+
17+
pixels = neopixel.NeoPixel(ss, neo_pin, num_pixels, brightness = 0.1)
18+
19+
color_offset = 0
20+
21+
while True:
22+
for i in range(num_pixels):
23+
rc_index = (i * 256 // num_pixels) + color_offset
24+
pixels[i] = colorwheel(rc_index & 255)
25+
pixels.show()
26+
color_offset += 1
27+
time.sleep(0.01)

0 commit comments

Comments
 (0)