/ 3D_Printed_Guardian_Sword / 3D_Printed_Guardian_Sword.ino
3D_Printed_Guardian_Sword.ino
1 // SPDX-FileCopyrightText: 2018 Mikey Sklar for Adafruit Industries 2 // 3 // SPDX-License-Identifier: MIT 4 5 #include <Adafruit_NeoPixel.h> 6 #ifdef __AVR__ 7 #include <avr/power.h> 8 #endif 9 10 // Which pin on the Arduino is connected to the NeoPixels? 11 // On a Trinket or Gemma we suggest changing this to 1 12 #define PIN 4 13 14 // Color Segments 15 #define APIXELS 14 // number of first orange pixels 16 #define BPIXELS 84 // number of blue pixels 17 #define CPIXELS 93 // second orange pixels 18 19 // When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals. 20 // Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest 21 // example for more information on possible values. 22 Adafruit_NeoPixel pixels = Adafruit_NeoPixel(93, PIN, NEO_GRB + NEO_KHZ800); 23 24 int delayval = 10; // delay for half a second 25 26 void setup() { 27 // This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket 28 #if defined (__AVR_ATtiny85__) 29 if (F_CPU == 16000000) clock_prescale_set(clock_div_1); 30 #endif 31 // End of trinket special code 32 33 pixels.begin(); // This initializes the NeoPixel library. 34 } 35 36 void loop() { 37 38 // For the first 14 pixels, make them orange, starting from pixel number 0. 39 for(int i=0;i<APIXELS;i++){ 40 pixels.setPixelColor(i, pixels.Color(255,50,0)); // Set Pixels to Orange Color 41 pixels.show(); // This sends the updated pixel color to the hardware. 42 delay(delayval); // Delay for a period of time (in milliseconds). 43 } 44 45 // Fill up 84 pixels with blue, starting with pixel number 14. 46 for(int i=14;i<BPIXELS;i++){ 47 pixels.setPixelColor(i, pixels.Color(0,250,200)); // Set Pixels to Blue Color 48 pixels.show(); // This sends the updated pixel color to the hardware. 49 delay(delayval); // Delay for a period of time (in milliseconds). 50 51 } 52 53 // Fill up 9 pixels with orange, starting from pixel number 84. 54 for(int i=84;i<CPIXELS;i++){ 55 pixels.setPixelColor(i, pixels.Color(250,50,0)); //Set Pixels to Orange Color 56 pixels.show(); // This sends the updated pixel color to the hardware. 57 delay(delayval); // Delay for a period of time (in milliseconds). 58 } 59 }