Voting resources, early voting, and poll worker information - VOTE. ... Adafruit is open and shipping.
0

Two Strips, One Microcontroller
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Two Strips, One Microcontroller

by synergycraft on Sun Jan 12, 2020 8:06 pm

Hello all,

First off I am new to LEDs and coding so any patience is appreciated! :^)

The project I am working on has lights start on either side and meet in the middle. Since I am using the strandtest code as a base, I have found a way to make one side work exactly how I want it. I would much rather have two strips doing the same code than have to figure out how to make it start on both ends and meet in the middle.

When attaching both strips to the microcontroller, can I solder both strands to the same pins?

Unrelated question... I removed the JST pin from the end of my strand of Neopixels. Should I solder both GND wires together or can I just clip one of them off completely?

Thanks in advance!!

synergycraft
 
Posts: 4
Joined: Wed Jan 08, 2020 1:02 pm

Re: Two Strips, One Microcontroller

by mikeysklar on Sun Jan 12, 2020 9:23 pm

Hello synergycraft,

This is a interesting problem as there are many ways to make the code do what you want.

Personally, I think the most intuitive thing is to actually use two pins on the microcontroller and run two loops. One counting up through the LEDs and the other counting down. Then there is a lot less "cleverness" involved.

You can drive both sets of Neopixels from a single pin. Normally you would wire the strips in serial end to end so it just looks like a much longer strip. Eg. If each strip is 64 pixels you would now have a single 128 pixel strip where soldered together the end of one strips 5v, GND, INPUT to the beginning other next strips. I've used this setup for 1500+ LED installation and it worked great.

mikeysklar
 
Posts: 1743
Joined: Mon Aug 01, 2016 8:10 pm

Re: Two Strips, One Microcontroller

by synergycraft on Mon Jan 13, 2020 1:17 am

mikeysklar wrote:Hello synergycraft,

This is a interesting problem as there are many ways to make the code do what you want.


Very good point. I have been avoiding that since I know practically nothing about the coding.

Any suggestions on how to alter this to make it count down from the last pixel? I'm using 60 pixels overall.


void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256*5; j++) {
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}

synergycraft
 
Posts: 4
Joined: Wed Jan 08, 2020 1:02 pm

Re: Two Strips, One Microcontroller

by synergycraft on Mon Jan 13, 2020 2:52 pm

Coding solution found. I am now turning each pixel on and off. I want groups of pixels as it moves forward and for the group to fade off on either end.
The way I'm doing it is quite tedious, but fine by me as I don't know more complex ways of coding. It also makes it much easier to visualize how each step will look.

Something like this:

strip.setPixelColor(0, 0, 16, 0);
strip.setPixelColor(1, 0, 0, 0);
strip.setPixelColor(2, 0, 0, 0);
strip.setPixelColor(3, 0, 0, 0);
strip.setPixelColor(4, 0, 0, 0);
strip.setPixelColor(5, 0, 0, 0);
strip.setPixelColor(6, 0, 0, 0);
strip.setPixelColor(7, 0, 0, 0);
strip.setPixelColor(8, 0, 0, 0);
strip.setPixelColor(9, 0, 0, 0);
strip.setPixelColor(10, 0, 0, 0);
strip.setPixelColor(11, 0, 16, 0);
strip.setPixelColor(12, 0, 32, 0);
strip.setPixelColor(13, 0, 64, 0);
strip.setPixelColor(14, 0, 128, 0);
strip.setPixelColor(15, 0, 255, 0);
strip.setPixelColor(16, 0, 255, 0);
strip.setPixelColor(17, 0, 128, 0);
strip.setPixelColor(18, 0, 64, 0);
strip.setPixelColor(19, 0, 32, 0);
strip.setPixelColor(20, 0, 16, 0);
strip.setPixelColor(21, 0, 0, 0);
strip.setPixelColor(22, 0, 0, 0);
strip.setPixelColor(23, 0, 0, 0);
strip.setPixelColor(24, 0, 0, 0);
strip.setPixelColor(25, 0, 0, 0);
strip.setPixelColor(26, 0, 0, 0);
strip.setPixelColor(27, 0, 0, 0);
strip.setPixelColor(28, 0, 0, 0);
strip.setPixelColor(29, 0, 0, 0);

strip.setPixelColor(30, 0, 0, 0);
strip.setPixelColor(31, 0, 0, 0);
strip.setPixelColor(32, 0, 0, 0);
strip.setPixelColor(33, 0, 0, 0);
strip.setPixelColor(34, 0, 0, 0);
strip.setPixelColor(35, 0, 0, 0);
strip.setPixelColor(36, 0, 0, 0);
strip.setPixelColor(37, 0, 0, 0);
strip.setPixelColor(38, 0, 0, 0);
strip.setPixelColor(39, 0, 16, 0);
strip.setPixelColor(40, 0, 32, 0);
strip.setPixelColor(41, 0, 64, 0);
strip.setPixelColor(42, 0, 128, 0);
strip.setPixelColor(43, 0, 255, 0);
strip.setPixelColor(44, 0, 255, 0);
strip.setPixelColor(45, 0, 128, 0);
strip.setPixelColor(46, 0, 64, 0);
strip.setPixelColor(47, 0, 32, 0);
strip.setPixelColor(48, 0, 16, 0);
strip.setPixelColor(49, 0, 0, 0);
strip.setPixelColor(50, 0, 0, 0);
strip.setPixelColor(51, 0, 0, 0);
strip.setPixelColor(52, 0, 0, 0);
strip.setPixelColor(53, 0, 0, 0);
strip.setPixelColor(54, 0, 0, 0);
strip.setPixelColor(55, 0, 0, 0);
strip.setPixelColor(56, 0, 0, 0);
strip.setPixelColor(57, 0, 0, 0);
strip.setPixelColor(58, 0, 0, 0);
strip.setPixelColor(59, 0, 16, 0);
strip.show();
delay(20);

synergycraft
 
Posts: 4
Joined: Wed Jan 08, 2020 1:02 pm

Re: Two Strips, One Microcontroller

by mikeysklar on Mon Jan 13, 2020 4:53 pm

Hey synergycraft,

Glad you found something that works.

You could of course loop through the sections where you are all zeros to simplify the code. Then have the manual settings in between the loops. Hardly an elegant solution, but greatly reduces the code length.

uint16_t i;

for(i=1; i<=10; i++) {
strip.setPixelColor(i,0,0,0);
}

for(i=21; i<=38; i++) {
strip.setPixelColor(i,0,0,0);
}

for(i=49; i<=58; i++) {
strip.setPixelColor(i,0,0,0);
}

mikeysklar
 
Posts: 1743
Joined: Mon Aug 01, 2016 8:10 pm

Re: Two Strips, One Microcontroller

by synergycraft on Mon Jan 13, 2020 8:36 pm

Oh I hadn't even considered the for function. I will have to consider that for future projects. I've already typed it out long hand already. I know it's excessive but it was a really nice way to help me visualize what pixels I wanted on or off.

synergycraft
 
Posts: 4
Joined: Wed Jan 08, 2020 1:02 pm

Re: Two Strips, One Microcontroller

by BlueSol on Thu Jan 23, 2020 2:38 pm

I'm working on something similar, is there a function to call just odd or even numbers?

BlueSol
 
Posts: 12
Joined: Wed Oct 30, 2019 1:57 am

Re: Two Strips, One Microcontroller

by mikeysklar on Fri Jan 24, 2020 2:15 pm

I would use a for loop to select between odd and even pixels.

// odd numbers
for(i=1; i<=64; i+2) {
strip.setPixelColor(i,0,0,0);
}

// even numbers
for(i=0; i<=64; i+2) {
strip.setPixelColor(i,0,0,0);
}

mikeysklar
 
Posts: 1743
Joined: Mon Aug 01, 2016 8:10 pm

Please be positive and constructive with your questions and comments.