How do I make this just run once and not repeat over and over?
#include <FastLED.h>
// How many leds in your strip?
#define NUM_LEDS 150
// For led chips like WS2812, which have a data line, ground, and power, you just
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
// Clock pin only needed for SPI based chipsets when not using hardware SPI
#define LED_PIN 4
#define CLOCK_PIN 13
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup () {
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(50);
delay(20);
}
void loop () {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::White;
FastLED.show();
delay(5);
leds[i] = CRGB::Black;
}
}
Great that worked.
I'm just figuring out how to do all this so, if I want to add a button to trigger these leds (instead of pushing the Arduino reset) can I do that?
Thanks to you all, It works like a charm!
(I am starting to understand this now)
In this code there is a #define CLOCK_PIN 13
What is this for?
Also if I wanted to change every other led to yellow can I do that?
#include <FastLED.h>
// How many leds in your strip?
#define NUM_LEDS 150
// For led chips like WS2812, which have a data line, ground, and power, you just
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
// Clock pin only needed for SPI based chipsets when not using hardware SPI
#define LED_PIN 4
#define BUTTON_PIN 5
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup () {
pinMode(BUTTON_PIN, INPUT_PULLUP);
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(50);
delay(20);
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::White;
FastLED.show();
delay(5);
leds[i] = CRGB::Black;
}
}
void loop () {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::White;
FastLED.show();
delay(5);
leds[i] = CRGB::Black;
}
while(digitalRead(BUTTON_PIN));
}
Ok so I have this code and want to have the first 20 leds flash for 1 sec then the next 20 to flash for 1 sec and so on, how do I do this? (I'm learning alot from all of you right now,,,,thanks)
#include <FastLED.h>
// How many leds in your strip?
#define NUM_LEDS 150
// For led chips like WS2812, which have a data line, ground, and power, you just
// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
// Clock pin only needed for SPI based chipsets when not using hardware SPI
#define LED_PIN 4
#define BUTTON_PIN 5
// Define the array of leds
CRGB leds[NUM_LEDS];
void setup () {
pinMode(BUTTON_PIN, INPUT_PULLUP);
FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(255);
delay(20);
for (int i = 0; i < NUM_LEDS; i++) {
if (i % 2 == 0)
if (i % 2 == 0)
leds[i] = CRGB::White;
else
leds[i] = CRGB::Yellow;
else
leds[i] = CRGB::Yellow;
FastLED.show();
delay(5);
leds[i] = CRGB::Black;
}
}
void loop () {
for (int i = 0; i < NUM_LEDS; i++) {
if (i % 2 == 0)
leds[i] = CRGB::White;
else
leds[i] = CRGB::Yellow;
FastLED.show();
delay(5);
leds[i] = CRGB::Black;
}
while(digitalRead(BUTTON_PIN));
}
Let's see what you've tried to make this happen. So far I see a sketch that doesn't seem to attempt to do anything involve 20 LEDs or one second. What's your best attempt so far?
PS: I understand/recognize that the code you posted is simply what you were handed here: How do I stop this? - #11 by vallka
However, if this is a continuation of that thread, why not post your follow-up question there?
And if this is a new/separate question, why copy the unrelated code from that thread here?
Your two or more topics on the same or similar subject have been merged.
Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.
Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.
Repeated duplicate posting could result in a temporary or permanent ban from the forum.
Could you take a few moments to Learn How To Use The Forum
It will help you get the best out of the forum in the future.
I kinda understand this but have no idea how to add this to the code I have. The way I learn is to have a code and play with it, I did this with a code this site gave me for a motor.
Just want to thank you all for the help on this one, I'm not going to add the groupings because I can't figure it out and am on a time constraint. Will look into this at a later date.
Thanks again.