Go Down

Topic: Trying to control 2 strips of WS2801 with Arduino Nano (Read 781 times) previous topic - next topic

JollySonX

Hello All, a complete Newbie here so please be gentle.

I eventually want 2 strips of 4 LEDs each to do some pretty things with 2 or 3 buttons, Im along way from the button pushing part, and I'm happy to stumble over that bridge when I come to it.

For the last few days I've been googling as much as I could with every possible search term I could think of and I've unfortunately had no luck. I've been reluctant to signing up and asking for help because I'm sure its already out there in the interweb some where. Also I personally I don't like to ask for help.

What I'm trying to do is, as the title says is control 2 strips of WS2801 LEDS from an arduino nano, I have played with some different examples, and have used the Strandtest example from the Adafruit WS2801 library I have managed to get both strips doing different things by creating this

Code: [Select]

Adafruit_WS2801 strip = Adafruit_WS2801(4, dataPin1, clockPin1);
Adafruit_WS2801 strip2 = Adafruit_WS2801(4, dataPin2, clockPin2);


and also this

Code: [Select]

  strip.begin();
  strip2.begin();
  // Update LED contents, to start they are all 'off'
  strip.show();
  strip2.show();


and then duplicating the colorWipe function(is function the correct word?) and calling it colorWipe2 and this does perform both colorWipe sequences on the correct strips as expected, however it performs colorWipe2 after it finishes colorWipe
my end result I would like both strips to run the same sequence in time with each other, but also be able to have different sequences after the push of a button.(again future me will be sorting the buttons out I don't care if he cant deal with that, that's his problem not mine)

I'm not asking for an easy hand out here, I just hope someone can give me better terminology to search google for answers. I'm definitely happy enough to do the leg work looking and bodging and trying different ideas, but I've reached the point where I need someone to step in and say something like, you need to search for blah blah blah, unless I'm wrong and what I'm asking for is impossible, with out the aid of a Flux capacitor and a really nice Delorean. then please tell me so, and put me out of my misery lol

Many Thanks.

Cam. 

(ps I've attached said code, in case I confused anyone with my poor explanation)

ieee488

Are the two strips suppose to show the same thing?


PaulRB

Are the two strips suppose to show the same thing?
Answer:
Quote
I would like both strips to run the same sequence in time with each other, but also be able to have different sequences after the push of a button.

PaulRB

Hi Cam and welcome to the forum.

Quote
complete Newbie here so please be gentle
When forum members are not gentle with newbies, the reason is almost always the same. The newby has not read (or not followed) the forum guidelines in the sticky post which is at the top of every forum section.

Please post your code in code tags. Most forum members use phones and tablets most of the time and cannot open .ino attachments. The sticky post at the top of the forum section will show you how, and other useful stuff to get the most out of the forum, so please read it.

Is there a reason why you have connected the two strips to two pairs of Arduino pins, instead of daisy-chaining the two strips so that only one pair of pins is needed?

Quote
however it performs colorWipe2 after it finishes colorWipe
You were not very clear what exactly you need help with, saying that your "future self" would sort out some problems. So is this the thing you are asking for help with today? If so, this is one of the most commonly asked questions asked by beginners on this forum. How to get more than one thing to run at the same time. For example how to run two patterns at once (either the same pattern or two different patterns) or how to run a pattern and simultaneously monitor a button to see if it had been pushed. This post will show you the technique you need to use. It boils down to this: the delay() function is your enemy, but getting rid of it is not easy.

Grumpy_Mike

#4
May 26, 2018, 09:38 am Last Edit: May 26, 2018, 09:40 am by Grumpy_Mike
What you need to do is to implement your colour changing patterns as a "state machine", I have posted examples of this a few times in this forum. It is based on the techniques used in the blink without delay example in the IDE.

Basically you have to interleaved the two colour changing functions with just one step for each and then display.

Like my reply here
https://forum.arduino.cc/index.php?topic=412232.0

JollySonX

Please post your code in code tags. Most forum members use phones and tablets most of the time and cannot open .ino attachments. The sticky post at the top of the forum section will show you how, and other useful stuff to get the most out of the forum, so please read it.
My Apologies, I will remember this for further posts.

Is there a reason why you have connected the two strips to two pairs of Arduino pins, instead of daisy-chaining the two strips so that only one pair of pins is needed?

 
You were not very clear what exactly you need help with, saying that your "future self" would sort out some problems. So is this the thing you are asking for help with today? If so, this is one of the most commonly asked questions asked by beginners on this forum. How to get more than one thing to run at the same time. For example how to run two patterns at once (either the same pattern or two different patterns) or how to run a pattern and simultaneously monitor a button to see if it had been pushed. This post will show you the technique you need to use. It boils down to this: the delay() function is your enemy, but getting rid of it is not easy.

Basically to save on wiring I used to different pins, they will eventually be mounted on a bike at the front and back, and didn't want the wires to run away from the Arduino and then back past it, would it be easier in the long run to have them in 1 long chain?

Your right not one of my better posts I'll admit, I shouldn't have mentioned the buttons at all for now
yes it was getting 2 patterns to run at once

Thanks for the Reply.

What you need to do is to implement your colour changing patterns as a "state machine", I have posted examples of this a few times in this forum. It is based on the techniques used in the blink without delay example in the IDE.

Basically you have to interleaved the two colour changing functions with just one step for each and then display.

Like my reply here
https://forum.arduino.cc/index.php?topic=412232.0
Many Thanks for the reply.

I will read up on the links you both have kindly supplied, and hopefully I'll be able to work something out and wont need to ask again

Go Up