#include <Adafruit_NeoPixel.h>
#define PIN 6
bool has_run = false;
Adafruit_NeoPixel strip = Adafruit_NeoPixel(16, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
// put your setup code here, to run once:
strip.begin();
strip.show(); // Initialize pixels 'off'
}
void blink(uint8_t id_pixel){
for(uint8_t i=0; i<6; i++){
strip.setPixelColor(id_pixel, strip.Color(255,0,0));
strip.show();
delay(100);
strip.setPixelColor(id_pixel, strip.Color(0,0,0));
strip.show();
delay(100);
}
}
void scan_dig(uint16_t wait, uint8_t pixel_start, uint8_t pixel_end,
uint32_t color = strip.Color(255,255,255), bool forward = true){
// Input Check
if((pixel_start - pixel_end) * forward * -1 < 0){
blink(0);
}
else{
switch(forward){
case true:
for(uint8_t i=pixel_start; i<pixel_end+1; i++){
// Disable Previous
if(i>pixel_start){
strip.setPixelColor(i-1,strip.Color(0,0,0));
strip.show();
}
//Enable Next
strip.setPixelColor(i,color);
strip.show();
delay(wait);
}
// Turn Off Last Pixel
strip.setPixelColor(pixel_end, strip.Color(0,0,0));
strip.show();
break;
case false:
for(int8_t i=pixel_start; i>pixel_end-1; i--){
// Disable Previous
if(i<pixel_start){
strip.setPixelColor(i+1,strip.Color(0,0,0));
strip.show();
}
//Enable Next
strip.setPixelColor(i,color);
strip.show();
delay(wait);
}
// Turn Off Last Pixel
strip.setPixelColor(pixel_end, strip.Color(0,0,0));
strip.show();
break;
}
}
}
void loop() {
// put your main code here, to run repeatedly:
if(!has_run){
scan_dig(500, 4, 0, strip.Color(0,255,0), false);
delay(1000);
scan_dig(250, 0, strip.numPixels()+1, strip.Color(255,255,255), true);
// scan_dig(1000, 5, 2, true);
has_run = true;
}
}
void scan(uint16_t wait){
for(uint16_t i=0; i<strip.numPixels(); i++){
// Disable Previous
if(i > 0){
strip.setPixelColor(i-1,strip.Color(0,0,0));
strip.show();
}
// Enable Next
strip.setPixelColor(i,strip.Color(255,255,255));
strip.show();
delay(wait);
}
// Turn Last Pixel Off
strip.setPixelColor(strip.numPixels()-1,strip.Color(0,0,0));
strip.show();
}
nano:12
nano:11
nano:10
nano:9
nano:8
nano:7
nano:6
nano:5
nano:4
nano:3
nano:2
nano:GND.2
nano:RESET.2
nano:0
nano:1
nano:13
nano:3.3V
nano:AREF
nano:A0
nano:A1
nano:A2
nano:A3
nano:A4
nano:A5
nano:A6
nano:A7
nano:5V
nano:RESET
nano:GND.1
nano:VIN
nano:12.2
nano:5V.2
nano:13.2
nano:11.2
nano:RESET.3
nano:GND.3
ring1:GND
ring1:VCC
ring1:DIN
ring1:DOUT