Hi everybody
I am new in dealing with Arduino. I am carrying out a personal project to simply learn how to control the lighting colours of the two RGB LED Neopixel rings (16x pixels each) using Arduino UNO and two different digital pins (3 and 6). Both RGB rings are powered by 5V from Arduino and grounded.
The idea of my project is to simply light both rings sequentially (one in a time). When the first ring turns green for 5 seconds, it will turn OFF and the second ring will turn blue for 2 seconds. Thereafter the second ring will turn OFF to allow the first ring turning red for 5 seconds. While the first ring is now red, the second ring must turn blue for 2 seconds before both two rings turn OFF to start the sequence from the beginning.
I wrote the code and used Tinkercad (www.tinkercad.com) for simulation which was a success. I also uploaded the code successfully into the Ardunio UNO. Unfortunately, when “physically” executing the code, the two rings follow the sequence above at once (i.e. with no LOOP). After that the second ring only starts to repeat the blue colour several times indicating that the circuit does not follow the complete loop I wrote.
I think I am missing something to allow running the colour sequence loop forever. I would appreciate your kind help.
Kindly find attached the circuit diagram, the code and the TinkerCad simulation link.
Thanks
#include <Adafruit_NeoPixel.h>
#define PIN 3 // input pin Neopixel is attached to
#define PIN 6 // input pin Neopixel is attached to
#define NUMPIXELS 16 // number of neopixels in Ring
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, 6, NEO_GRB + NEO_KHZ800);
int delayval = 5; // timing delay
void setup() {
pixels.begin(); // Initializes the NeoPixel library.
pixels.setBrightness(25); // Lower brightness and save eyeballs!
pixels.show(); // Initialize all pixels to 'off'
// Serial.begin(9600);
}
void loop() //defined a loop function
{
/********************************************************************/
for(int i=0;i<NUMPIXELS;i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, pixels.Color(0,250,0)); // Moderately bright green color.
pixels.setBrightness(25); // Lower brightness and save eyeballs!
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
/**************************************************************************/
delay(5000); /// this for how much time green color stays in mS
for(int i=0;i<NUMPIXELS;i++){
pixels.setPixelColor(i, pixels.Color(0,0,0)); // Ring (all 16 pixels)in PIN 6 is OFF (Green OFF).
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
/**************************************************************************/
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, 3, NEO_GRB + NEO_KHZ800);
pixels.begin(); // Initializes the NeoPixel library.
for(int i=0;i<NUMPIXELS;i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, pixels.Color(0,0,250)); // Moderately bright Blue color.
pixels.setBrightness(25); // Lower brightness and save eyeballs!
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
/***********************************************************************/
delay(3000); // this for how much time orange color stays in mS
/*******************************************************/
for(int i=0;i<NUMPIXELS;i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, pixels.Color(0,0,0)); // Ring (all 16 pixels)in PIN 3 is OFF (Blue OFF).
pixels.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
/*******************************************************/
Adafruit_NeoPixel pixels6 = Adafruit_NeoPixel(NUMPIXELS, 6, NEO_GRB + NEO_KHZ800);
for(int i=0;i<NUMPIXELS;i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels6.setPixelColor(i, pixels6.Color(250,0,0)); // Moderately bright red color.
pixels6.setBrightness(25); // Lower brightness and save eyeballs!
pixels6.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
/***************************************************************/
delay(5000); // this for how much time Red color stays in mS
/*******************************************************/
Adafruit_NeoPixel pixels3 = Adafruit_NeoPixel(NUMPIXELS, 3, NEO_GRB + NEO_KHZ800);
for(int i=0;i<NUMPIXELS;i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels3.setPixelColor(i, pixels3.Color(0,0,250)); // Moderately bright Blue color.
pixels3.setBrightness(25); // Lower brightness and save eyeballs!
pixels3.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
/***********************************************************************/
delay(3000); // this for how much time orange color stays in mS
/*******************************************************/
for(int i=0;i<NUMPIXELS;i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels3.setPixelColor(i, pixels3.Color(0,0,0)); // Ring (all 16 pixels)in PIN 3 is OFF (Blue OFF).
pixels3.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
/*******************************************************/
for(int i=0;i<NUMPIXELS;i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels6.setPixelColor(i, pixels6.Color(0,0,0)); // Ring (all 16 pixels)in PIN 6 is OFF (Red OFF).
pixels6.show(); // This sends the updated pixel color to the hardware.
delay(delayval); // Delay for a period of time (in milliseconds).
}
}
