#include "application.h"
#include "neopixel.h"
// IMPORTANT: Set pixel COUNT, PIN and TYPE
#define PIXEL_COUNT 24
#define PIXEL_PIN D2
#define PIXEL_PIN1 D3
#define PIXEL_TYPE WS2812B
#define YELLOW 130,110,0
#define PURPLE 180,3,180
#define BLUE 5,5,190
#define RED 255,0,0
#define GREEN 10,180,10
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
Adafruit_NeoPixel strip1 = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN1, PIXEL_TYPE);
int waitTime = 10;
int i;
int buttonPin = D0;
int buttonValue = LOW;
void spin(int R, int G, int B);
void spin1(int R, int G, int B);
void setup()
{
strip.begin();
strip.show();
strip1.begin();
strip1.show();
pinMode(buttonPin, INPUT);
//pinMode(PIXEL_PIN, OUTPUT);
}
void loop()
{
buttonValue = digitalRead(buttonPin);
if( buttonValue == LOW)
{
//spin (YELLOW);
//spin (PURPLE);
//spin (BLUE);
//spin (RED);
spin (RED);
spin1 (RED);
}
else
{
spin(GREEN);
spin1(GREEN);
}
}
void spin(int R, int G, int B)
{
for(i=0; i < PIXEL_COUNT; i++) {
strip.setPixelColor(i, R,G,B);
strip.show();
delay(waitTime);
}
for(i=0; i < PIXEL_COUNT; i++) {
strip.setPixelColor(i, R,G,B);
strip.show();
delay(waitTime);
}
}
void spin1(int R, int G, int B)
{
for(i=0; i < PIXEL_COUNT; i++)
{
strip1.setPixelColor(i, R,G,B);
strip1.show();
delay(waitTime);
}
for(i=0; i < PIXEL_COUNT; i++)
{
strip1.setPixelColor(i, R,G,B);
strip1.show();
delay(waitTime);
}
}
Click to Expand
Content Rating
Is this a good/useful/informative piece of content to include in the project? Have your say!
You must login before you can post a comment. .