Notifications
Clear all

Theatre chase in opposite directions.

155 Posts
6 Users
2 Likes
11.9 K Views
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2535
 

@davy-ps 

Good. Note that it will run with any number of LEDs, all you need to do is change the value of NUM_LEDS.

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Davy PS
(@davy-ps)
Member
Joined: 2 years ago
Posts: 74
Topic starter  

Will and robotBuilder. Thanks a lot for your help. Six weeks ago I thought Arduino played centre forward for Real Madrid. 😉 So you can see why I'm all over the place. I am beginning to pick up things here and there and will spend next few days {after tonight's shennanigans) trying to figure out for myself how you arrive at your sketches.

Thanks again.

Happy New Year.

Davy.


   
ReplyQuote
Davy PS
(@davy-ps)
Member
Joined: 2 years ago
Posts: 74
Topic starter  

@will Mate just a quick one on this sketch. (Davy4). Can we add a second colour to the loop? IE Green a couple of times then change to red for a couple of times and then back to green or some other colour?

 

Thanks Mate,

 

Davy.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2535
 
Posted by: @davy-ps

@will Mate just a quick one on this sketch. (Davy4). Can we add a second colour to the loop? IE Green a couple of times then change to red for a couple of times and then back to green or some other colour?

Try this ...

 

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2043
 

@will

@davy-ps

Never ending variations 🙂

How about a red dot moving one way and a green dot moving the other way? They could move through each other or bounce off each other.

the fastLED library certainly makes controlling self addressing LED strips and other LED displays interesting. Another variation I saw online is having leading and receding brightness values for the "moving" pixels.

After New Year sometime I will have to get some addressable digital LED pixel strips to play with.

 


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2535
 

@robotbuilder 

They can be a lot of fun (especially if you have a cat 🙂

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Davy PS
(@davy-ps)
Member
Joined: 2 years ago
Posts: 74
Topic starter  

@will 

Hi Will,

           Have been playing around with this sketch you sent and have added more colours. Is there an instruction I can add in the loop function to have two different colours starting from each end?

 

Cheers,

Davy.

[code]
#include <Adafruit_NeoPixel.h>
#include <FastLED.h>

#define LED_PIN 4
#define NUM_LEDS 10
#define NUM_COLOURS 6
#define NUM_REPEATS 1
// Define colours used
CRGB colourOn = CRGB(255, 0, 0);
CRGB colourOff = CRGB(0, 0, 0);
CRGB colourList[6] = {CRGB(55,55,55),CRGB(55,0,55),CRGB(0,55,55),CRGB(255, 0, 0),CRGB(0,255, 0),CRGB(0,0,255),};
CRGB leds[NUM_LEDS];
// Define times for colour on and colour off in millis
int lengthOn=100, lengthOff = 100;

void setup() {
// Setup Serial Monitor
Serial.begin(9600);
// Setup FastLED object
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(250);
// Turn allLEDs off
for (int i = 0; i < NUM_LEDS; ++i) {
leds[i] = CRGB(0, 0, 0);
}
}
void loop() {
for (int c=0;c<NUM_COLOURS;c++) { // For each colour in list
colourOn = colourList[c]; // Switch colours
for (int r=0;r<NUM_REPEATS;r++) { // For each repeat count
for (int i=0;i<NUM_LEDS;i++) { // For each index
leds[i] = colourOn; // Set colour into index
leds[NUM_LEDS-i] = leds[i]; // Set same colour at other end
FastLED.show(); // Clear LED for next index
delay(lengthOn); // Pause for effect to show
leds[NUM_LEDS-i] = colourOff; // Clear colour
leds[i] = colourOff;
FastLED.show(); // Clear LED for next index
delay(lengthOff); // Wait for next cycle
} // for index
} // for repeat
} // for colour
}
[/code]


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2535
 
Posted by: @davy-ps

@will 

Hi Will,

           Have been playing around with this sketch you sent and have added more colours. Is there an instruction I can add in the loop function to have two different colours starting from each end?

Sure, this one uses the colours forwards in th colour list for the LEDs moving forward and backwards in the colour list for LEDs moving backwards.

 

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Davy PS
(@davy-ps)
Member
Joined: 2 years ago
Posts: 74
Topic starter  

Hi Will,

           Thanks for that. davy6 runs from 0 to 9 then changes colour and repeats. It doesn't, run from 0 to 9 and 9 to 0 simultaneously as in davy5. What I was after was 0-9 in red for example and 9-0 simultaneously in blue for example. A curious thing too with davy 6. LED 6 is not going HIGH.. Connection is good???????

Any ideas?

Thanks again for your valuable help.

 

Davy.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2535
 

@davy-ps 

You seem to have switched from NUM_LEDS=9 to NUM_LEDS=10. Was that intentional ?

Try this (I've switched back to NUM_LEDS=9, change this if required).

 

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
Davy PS
(@davy-ps)
Member
Joined: 2 years ago
Posts: 74
Topic starter  

@will 

Hi Will. First attempt posting on YouTube. Hope it works. This is the sequence from your davy5 sketch you sent me. What I would like to do if possible is have the sketch running the same way but having two different colours running opposite each other.

Regarding davy7 and changing to 10 LEDS. Yes I had changed from 9 to 10 and it works on all other sketches. Funnilly enough though on your modified version when I put 10 in again LED 6 still wouldn't light from left to right but lit from right to left!

Cheers Mate.

Davy.


   
ReplyQuote
Will
 Will
(@will)
Member
Joined: 3 years ago
Posts: 2535
 

@davy-ps 

Does davy7 display the way you want (other than LED6) ?

Anything seems possible when you don't know what you're talking about.


   
ReplyQuote
robotBuilder
(@robotbuilder)
Member
Joined: 5 years ago
Posts: 2043
 

@davy-ps 

What I was after was 0-9 in red for example and 9-0 simultaneously in blue for example.

Like this?

LedSequence

 


   
ReplyQuote
Davy PS
(@davy-ps)
Member
Joined: 2 years ago
Posts: 74
Topic starter  

@robotbuilder 

Hi Robotbuilder. Yup That's it.

 

Davy.


   
ReplyQuote
Davy PS
(@davy-ps)
Member
Joined: 2 years ago
Posts: 74
Topic starter  

@will 

Hi Will. Yes it does. It's something I can make use of.

Cheers,

Davy.


   
ReplyQuote
Page 2 / 11