Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include <ESP8266WiFi.h>
- #include <Adafruit_NeoPixel.h>
- #define NUMCOLS 20
- #define NUMROWS 5
- #define NUMCOLORS 6
- //const char* ssid = "foobar";
- //const char* password = "ApplesAreGoodForYou";
- //const char* host = "wifitest.adafruit.com";
- Adafruit_NeoPixel rows[5];
- int frame = 0;
- int colors[4];
- int time=0;
- int last_frame=0;
- int frame_interval=50;
- void setup() {
- //setupSerial.begin(115200);
- //rows[0] = Adafruit_NeoPixel(NUMCOLS, 5, NEO_GRB + NEO_KHZ800);
- //rows[1] = Adafruit_NeoPixel(NUMCOLS, 2, NEO_GRBW + NEO_KHZ800);
- rows[0] = Adafruit_NeoPixel(NUMCOLS, 5, NEO_GRBW + NEO_KHZ800);
- rows[1] = Adafruit_NeoPixel(NUMCOLS, 2, NEO_GRBW + NEO_KHZ800);
- rows[2] = Adafruit_NeoPixel(NUMCOLS, 0, NEO_GRBW + NEO_KHZ800);
- rows[3] = Adafruit_NeoPixel(NUMCOLS, 13, NEO_GRBW + NEO_KHZ800);
- rows[4] = Adafruit_NeoPixel(NUMCOLS, 12, NEO_GRBW + NEO_KHZ800);
- delay(100);
- for(int y=0;y<NUMROWS;y++) {
- rows[y].begin();
- }
- colors[0] = rows[0].Color(200,0,0);
- colors[1] = rows[0].Color(100,100,0);
- colors[2] = rows[0].Color(0,200,0);
- colors[3] = rows[0].Color(0,100,100);
- colors[4] = rows[0].Color(0,0,200);
- colors[5] = rows[0].Color(100,0,100);
- digitalWrite(14, HIGH);
- }
- void white_swell(int frame) {
- for(int y=0;y<NUMROWS;y++) {
- for(int x=0;x<NUMCOLS;x++) {
- rows[y].setPixelColor(x, rows[0].Color(0,4*(frame % 62),0,0));
- }
- rows[y].show();
- }
- }
- void color_walk(int frame) {
- int position = frame % NUMCOLS;
- int color_id = ( frame / NUMCOLS ) % NUMCOLORS;//frame % NUMCOLORS;
- for(int y=0;y<NUMROWS;y++) {
- for(int x=0;x<NUMCOLS;x++) {
- if(position == x) rows[y].setPixelColor(x, colors[color_id]);
- else rows[y].setPixelColor(x, rows[0].Color(0,0,0));
- }
- rows[y].show();
- }
- }
- void color_sweep(int frame) {
- int new_color_id = (frame/NUMCOLS) % NUMCOLORS;
- int old_color_id = (new_color_id+NUMCOLORS-1) % NUMCOLORS;
- int cur_position = frame % NUMCOLS;
- for(int y=0;y<NUMROWS;y++) {
- for(int x=0;x<NUMCOLS;x++) {
- if(cur_position < x) rows[y].setPixelColor(x, colors[old_color_id]);
- else rows[y].setPixelColor(x, colors[new_color_id]);
- }
- rows[y].show();
- }
- }
- void dot_runner(int frame) {
- Serial.print("HI");
- int steps = 10;
- int total_steps = steps * NUMCOLS;
- int animation_frame = frame % total_steps;
- int col_position = animation_frame/steps % 8;
- float aa = (animation_frame - col_position*steps) / steps;
- Serial.print(aa);
- for(int y=0;y<NUMROWS;y++) {
- for(int x=0;x<NUMCOLS;x++) {
- if(col_position == x) rows[y].setPixelColor(x, 200 * aa, 0, 0,0);
- else rows[y].setPixelColor(x, 0,0,20,0);
- }
- rows[y].show();
- }
- }
- void loop() {
- if(last_frame + frame_interval < time) {
- color_sweep(frame);
- frame++;
- last_frame = time;
- }
- time = millis();
- }
Add Comment
Please, Sign In to add comment