ported to CircuitPython
This commit is contained in:
parent
76997a19de
commit
a2ebee3e6e
3 changed files with 108 additions and 0 deletions
55
3D_Printed_Guardian_Sword/3D_Printed_Guardian_Sword.ino
Normal file
55
3D_Printed_Guardian_Sword/3D_Printed_Guardian_Sword.ino
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
#include <Adafruit_NeoPixel.h>
|
||||
#ifdef __AVR__
|
||||
#include <avr/power.h>
|
||||
#endif
|
||||
|
||||
// Which pin on the Arduino is connected to the NeoPixels?
|
||||
// On a Trinket or Gemma we suggest changing this to 1
|
||||
#define PIN 4
|
||||
|
||||
// Color Segments
|
||||
#define APIXELS 14 // number of first orange pixels
|
||||
#define BPIXELS 84 // number of blue pixels
|
||||
#define CPIXELS 93 // second orange pixels
|
||||
|
||||
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
|
||||
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
|
||||
// example for more information on possible values.
|
||||
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(93, PIN, NEO_GRB + NEO_KHZ800);
|
||||
|
||||
int delayval = 10; // delay for half a second
|
||||
|
||||
void setup() {
|
||||
// This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
|
||||
#if defined (__AVR_ATtiny85__)
|
||||
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
|
||||
#endif
|
||||
// End of trinket special code
|
||||
|
||||
pixels.begin(); // This initializes the NeoPixel library.
|
||||
}
|
||||
|
||||
void loop() {
|
||||
|
||||
// For the first 14 pixels, make them orange, starting from pixel number 0.
|
||||
for(int i=0;i<APIXELS;i++){
|
||||
pixels.setPixelColor(i, pixels.Color(255,50,0)); // Set Pixels to Orange Color
|
||||
pixels.show(); // This sends the updated pixel color to the hardware.
|
||||
delay(delayval); // Delay for a period of time (in milliseconds).
|
||||
}
|
||||
|
||||
// Fill up 84 pixels with blue, starting with pixel number 14.
|
||||
for(int i=14;i<BPIXELS;i++){
|
||||
pixels.setPixelColor(i, pixels.Color(0,250,200)); // Set Pixels to Blue Color
|
||||
pixels.show(); // This sends the updated pixel color to the hardware.
|
||||
delay(delayval); // Delay for a period of time (in milliseconds).
|
||||
|
||||
}
|
||||
|
||||
// Fill up 9 pixels with orange, starting from pixel number 84.
|
||||
for(int i=84;i<CPIXELS;i++){
|
||||
pixels.setPixelColor(i, pixels.Color(250,50,0)); //Set Pixels to Orange Color
|
||||
pixels.show(); // This sends the updated pixel color to the hardware.
|
||||
delay(delayval); // Delay for a period of time (in milliseconds).
|
||||
}
|
||||
}
|
||||
49
3D_Printed_Guardian_Sword/3D_Printed_Guardian_Sword.py
Normal file
49
3D_Printed_Guardian_Sword/3D_Printed_Guardian_Sword.py
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
# 3D_Printed_Guardian_Sword
|
||||
# https://learn.adafruit.com/breath-of-the-wild-guardian-sword-led-3d-printed
|
||||
|
||||
import board
|
||||
import neopixel
|
||||
import time
|
||||
|
||||
pin = board.D4 # DIGITAL IO pin for NeoPixel OUTPUT from GEMMA
|
||||
pixel_count = 93 # number of neopixels
|
||||
delayval = .01 # 10 ms delay
|
||||
|
||||
APIXELS = 14 # number of first orange pixels
|
||||
BPIXELS = 84 # number of blue pixels
|
||||
CPIXELS = 93 # second orange pixels
|
||||
|
||||
# initialize neopixels
|
||||
pixels = neopixel.NeoPixel(pin, pixel_count, brightness=1, auto_write=False)
|
||||
|
||||
while True:
|
||||
|
||||
# For the first 14 pixels, make them orange,
|
||||
# starting from pixel number 0.
|
||||
for i in range( 0, APIXELS ):
|
||||
# Set Pixels to Orange Color
|
||||
pixels[i] = ( 255, 50, 0 )
|
||||
# This sends the updated pixel color to the hardware.
|
||||
pixels.write()
|
||||
# Delay for a period of time (in milliseconds).
|
||||
time.sleep(delayval)
|
||||
|
||||
# Fill up 84 pixels with blue,
|
||||
# starting with pixel number 14.
|
||||
for i in range ( 14, BPIXELS ):
|
||||
# Set Pixels to Orange Color
|
||||
pixels[i] = ( 0, 250, 200 )
|
||||
# This sends the updated pixel color to the hardware.
|
||||
pixels.write()
|
||||
# Delay for a period of time (in milliseconds).
|
||||
time.sleep(delayval)
|
||||
|
||||
# Fill up 9 pixels with orange,
|
||||
# starting from pixel number 84.
|
||||
for i in range ( 84, CPIXELS ):
|
||||
# Set Pixels to Orange Color
|
||||
pixels[i] = ( 250, 50, 0 )
|
||||
# This sends the updated pixel color to the hardware.
|
||||
pixels.write()
|
||||
# Delay for a period of time (in milliseconds).
|
||||
time.sleep(delayval)
|
||||
4
3D_Printed_Guardian_Sword/README.md
Normal file
4
3D_Printed_Guardian_Sword/README.md
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# 3D_Printed_Guardian_Sword
|
||||
|
||||
Code to accompany this tutorial:
|
||||
https://learn.adafruit.com/breath-of-the-wild-guardian-sword-led-3d-printed
|
||||
Loading…
Reference in a new issue