Hi, another simple question.I have modified some of the examples of different effects (4

Hi, another simple question.I have modified some of the examples of different effects (4 in total) and i would like to replay them separately from individual button from digital pins. I have the hardware side sorted using pull up resistors but i can’t seem to get my head round what code i need and where it gets inserted.
I am using 3.1 on an Arduino Uno

#include <FastLED.h>
#define NUM_LEDS 51
#define DATA_PIN 7

CRGB leds[NUM_LEDS];
void setup() {
delay(2000);
FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);
}
void loop() {
//fill_solid(leds, NUM_LEDS, CRGB::Red);
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Red;

FastLED.show();
delay(30);
}
}

Hi Ross Malyon, you need to go through the basic examples that came with the installation of the Arduino IDE.

Within the Arduino IDE, check the:

/files/examples/02.digital

section for many examples on how to handle digital inputs.

If you understand the basics of handling the state of a switch connected to a digital input pin, I guess the next step for you would be to learn about ‘Switch case’ handling. Again you can find some examples of how these work in:

/files/examples/05.Control

Except for a few variable declarations, all of the code you will need will be located inside the main loop().

You can do it !!

Hi again Ross Malyon,

I was just wondering how you are managing with that code that you were struggling with !?

I guess no news is good news… :slight_smile:

JP, thanks. It all complies ok, just have to see how it looks this weekend. I’ll let you know. I am using this for my college project (even though i am 50) to help me understand about C programming.

@Ross_Malyon Join the gang, I’m actually closer to 60 than 50 now :frowning: and semi-retired.

I have started with Arduino and RGB LEDs a bit more than a year ago to start playing with programming and only discovered this group a few months ago. I have received really great support here and I am very happy if I can help in return !