hey guys so i found this code on the internet but i tried to add more strips i commented it out but keeps getting errors could anyone help please.
where can i put the code so u guys can help me
hey guys so i found this code on the internet but i tried to add more strips i commented it out but keeps getting errors could anyone help please.
where can i put the code so u guys can help me
Read the forum guidelines to see how to properly post code and some good information on making a good post.
Use the IDE autoformat tool (ctrl-t or Tools, Auto format) before posting code in code tags.
Along with the code we need to know the exact LED strips that you have, the Arduino board that you are using and how the LED strips are connected and powered.
Please post a wiring diagram. Written descriptions are always more ambiguous than a drawing. Hand drawn, photographed and posted is fine. Include all pin names/numbers, components, their part numbers and/or values and power supplies.
ok i posted it im using a arduino uno with ws2812 neopixels with the adafruit library
so ive got 3 strips strip stripa and stripb so im not sure how to add them all cause i need all 3 strips to work together
You seem to have ignored the part about posting code properly.
Post all the code. Post the code in code tags. Post the code without all of the extra " " crap.
i still struggle lol im new on the sitre to code and to everything lol let me try
where can i find the guidlines on how to post code
#include <Adafruit_NeoPixel.h>
int dataPin = 6;
int dataPina = 7;
int dataPinb = 8;
#define numberOfPixels 58
#define maximumBrightness 50
#ifdef __AVR__
#include <avr/power.h>
#endif
Adafruit_NeoPixel strip = Adafruit_NeoPixel (numberOfPixels, dataPin);
Adafruit_NeoPixel stripa = Adafruit_NeoPixel (numberOfPixels, dataPina);
//Adafruit_NeoPixel stripb = Adafruit_NeoPixel (numberOfPixels,dataPinb);
void setup()
{
strip.begin();
stripa.begin();
//stripb.begin();
strip.show();
stripa.show();
//stripb.show();
strip.clear();
stripa.clear();
//stripb.clear();
}
void loop()
{
Test1();
}
void Test1()
{
setLightsToColour(10, 0, 10);
setLightsToColour(0, 0, 0);
setLightsToColour(50, 0, 0);
setLightsToColour(0, 0, 0);
setLightsToColour(0, 50, 0);
setLightsToColour(0, 0, 0);
setLightsToColour(0, 0, 50);
setLightsToColour(0, 0, 0);
rainbowCycle(5);
rainbow(20);
}
void setLightsToColour(int red, int green, int blue)
{
strip.show();
delay(500);
stripa.show();
delay(500);
for (uint8_t i = 0; i < numberOfPixels; i++)
{
strip.setPixelColor (i, strip.Color(red, green, blue));
stripa.setPixelColor (i, stripa.Color(red, green, blue));
//stripb.setPixelColor (i, stripb.Color(red,green,blue));
}
}
void Colour_fade()
{
}
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for (j = 0; j < 256 * 5; j++) { // 5 cycles of all colors on wheel
for (i = 0; i < strip.numPixels(); i++)
//(i = 0; i < stripa.numPixels(); i++)
// (i = 0; i < stripb.numPixels(); i++)
{
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
//stripa.setPixelColor(i, Wheel(((i * 256 / stripa.numPixels()) + j) & 255));
//stripb.setPixelColor(i, Wheel(((i * 256 / stripb.numPixels()) + j) & 255));
}
strip.show();
//stripa.show();
//stripb.show();
delay(wait);
}
}
// Currently setup to slowly fade the blue LEDs down the strip
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if (WheelPos < 85) {
return strip.Color(0, 0, WheelPos * 3);
//return stripa.Color(0, 0, WheelPos * 3);
//return stripb.Color(0, 0, WheelPos * 3);
}
if (WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, 255, 0 - WheelPos * 3);
//return stripa.Color(0, 0, 255 - WheelPos * 3);
//return stripb.Color(0, 0, 255 - WheelPos * 3);
}
WheelPos -= 170;
return strip.Color(0, 0, 0);
//return stripa.Color(0, 0, 0);
//return stripb.Color(0, 0, 0);
}
void rainbow(uint8_t wait) {
uint16_t k, o;
for (o = 0; o < 256; o++) {
for (k = 0; k < strip.numPixels(); k++) {
strip.setPixelColor(k, Wheel((k * 1 + o) & 255));
}
strip.show();
delay(wait);
}
}
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheels(byte WheelPoss) {
if (WheelPoss < 85) {
return strip.Color(WheelPoss * 3, 255 - WheelPoss * 3, 0);
}
else if (WheelPoss < 170) {
WheelPoss -= 85;
return strip.Color(255 - WheelPoss * 3, 0, WheelPoss * 3);
}
else {
WheelPoss -= 170;
return strip.Color(0, WheelPoss * 3, 255 - WheelPoss * 3);
}
}
I am not that familiar with the NeoPixel library but I do see the following:
The show function should come after clear. The clear function writes to the pixels then the show function outputs what was written.
Same with the setLightsToColour function. Use the for loops to set the colors in pixel memory then show to display the colors.
What does that code actually do? How is that different from what you want?
Ok well when i uncomented the comments the other strips on the pins didnt work so somehow it got pixed when i pressed ctrl+t now al 3 strips work sl. So what it does is it runs from the last picel to the fist pixel in a faded way from bright to dim. Now i was wondering how to get a gap between the different strips so that they wont run along with each other
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.