Go Down

Topic: noob needs some help with coding :) (Read 659 times) previous topic - next topic


i have arduino nano with WS2812B led strip 60 leds. my friend helped me out to combine all these effects, but now i want to be able to switch between them with ir remote, i have ir reciever and remote so what i need to add here for that to work??

#include "FastLED.h"


#if defined(FASTLED_VERSION) && (FASTLED_VERSION < 3001000)

#warning "Requires FastLED 3.1 or later; check github for latest code."


#define DATA_PIN    6

#define LED_TYPE    WS2811


#define NUM_LEDS    60


#define BRIGHTNESS          96

#define FRAMES_PER_SECOND  120

void setup() {

  delay(3000); // 3 second delay for recovery


  FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);



typedef void (*SimplePatternList[])();

SimplePatternList gPatterns = { rainbow, rainbowWithGlitter, confetti, sinelon, juggle, bpm };

uint8_t gCurrentPatternNumber = 0; // Index number of which pattern is current

uint8_t gHue = 0; // rotating "base color" used by many of the patterns


void loop()





  EVERY_N_MILLISECONDS( 20 ) { gHue++; }

  EVERY_N_SECONDS( 10 ) { nextPattern(); }


#define ARRAY_SIZE(A) (sizeof(A) / sizeof((A)[0]))

void nextPattern()


  gCurrentPatternNumber = (gCurrentPatternNumber + 1) % ARRAY_SIZE( gPatterns);


void rainbow()


  fill_rainbow( leds, NUM_LEDS, gHue, 7);


void rainbowWithGlitter()





void addGlitter( fract8 chanceOfGlitter)


  if( random8() < chanceOfGlitter) {

    leds[ random16(NUM_LEDS) ] += CRGB::White;



void confetti()


  // random colored speckles that blink in and fade smoothly

  fadeToBlackBy( leds, NUM_LEDS, 10);

  int pos = random16(NUM_LEDS);

  leds[pos] += CHSV( gHue + random8(64), 200, 255);


void sinelon()


  // a colored dot sweeping back and forth, with fading trails

  fadeToBlackBy( leds, NUM_LEDS, 20);

  int pos = beatsin16( 13, 0, NUM_LEDS-1 );

  leds[pos] += CHSV( gHue, 255, 192);


void bpm()


  // colored stripes pulsing at a defined Beats-Per-Minute (BPM)

  uint8_t BeatsPerMinute = 62;

  CRGBPalette16 palette = PartyColors_p;

  uint8_t beat = beatsin8( BeatsPerMinute, 64, 255);

  for( int i = 0; i < NUM_LEDS; i++) { //9948

    leds = ColorFromPalette(palette, gHue+(i*2), beat-gHue+(i*10));



void juggle() {

  // eight colored dots, weaving in and out of sync with each other

  fadeToBlackBy( leds, NUM_LEDS, 20);

  byte dothue = 0;

  for( int i = 0; i < 8; i++) {

    leds[beatsin16( i+7, 0, NUM_LEDS-1 )] |= CHSV(dothue, 200, 255);

    dothue += 32;





why if i need help, im not an expert


if i need help

. . . I don't want to get banned for CROSS-POSTING.


Welcome to the Forum. Please read these two posts:

How to use this forum - please read.
Read this before posting a programming question ...
You may also find useful information that would answer your question here:
Useful links - check here for reference posts / tutorials

You have posted code without using code tags. The code tags make the code look
Code: [Select]
like this
when posting source code files. It makes it easier to read, and can be copied with a single mouse click. Also, if you don't do it, some of the character sequences in the code can be misinterpred by the forum code as italics or funny emoticons.
If you have already posted without using code tags, open your message and select "modify" from the pull down menu labelled, "More", at the lower left corner of the message. Highlight your code by selecting it (it turns blue), and then click on the "</>" icon at the upper left hand corner. Click on the "Save" button. Code tags can also be inserted manually in the forum text using the code and /code metatags.

Unless the sketch is too large, it's better if you post your code, rather than attach it. When it's attached, we have to download it, create a folder then open your code in our IDE. And afterwards, the folder remains unless we navigate to the "Temp" folder and manually remove it. It's much easier to just view the code in your post.

Many questions can be answered by reading the documentation which is provided with the IDE, available under the help tab, or online here.

There are many other things that programmers do to make their code understandable. Please do them, as a courtesy to the members who volunteer their time to help you here. Use a standard indentation to clearly show the code blocks. Never put more than one statement per line. Place any brackets by themselves on a separate line. Use blank lines sparingly, no more than one at a time. Before posting the code, use Ctrl-T in the IDE to reformat the code in a standard format, which makes it easier for us to read.
  ... with a transistor and a large sum of money to spend ...
Please don't PM me with technical questions. Post them in the forum.

Go Up