How to select LED Ws2812B Effect by button.

Hi every-one i am make a toy for me :smiley:
I has found source code for LED effects at here:
and i want to use a button to select effects. But i am a mechanical student, i can't understand structure of the command line.
I try more time but can't do it. So can you help me - How to do it? or give me a sample? or what command i should use?

Not a great tutorial. It's barely better than reading the examples that come with the library.

Try this one: Adafruit Multi-Tasking Tutorial

You might be able to use this as a baseline. All it does is read a switch on pin 2 (pressed == GNDed) and bumps an option variable. You should be able to use that variable to cycle through the effect you want to show.

#define SW_READ_INTERVAL    50ul        //mS between switch reads

const byte pinSwitch = 2;


void setup( void )
    pinMode( pinSwitch, INPUT_PULLUP );
    swLast = digitalRead( pinSwitch );
    option = 0;

void loop( void )
    static byte
        lastOption = 0xff;

    //read the switch

    //show how option value changes when button pressed
    if( lastOption != option )
        lastOption = option;
        //print it to show the option value changed
        Serial.print( "Option " ); Serial.println( option );
    //your code could act on the value of option to select which effect to play

void ReadSwitch( void )
    unsigned long
    static unsigned long
        timeSwitch = 0;
    //check the time
    timeNow = millis();
    //has our switch read interval passed?
    if( (timeNow - timeSwitch) >= SW_READ_INTERVAL )
        //yes; set up for the next switch read
        timeSwitch = timeNow;

        //read the switch
        swNow = digitalRead( pinSwitch );
        //is is different than the last read value?
        if( swNow != swLast )
            //yes; save the new as last
            swLast = swNow;
            //if new is low it means the button was just pressed
            if( swNow == LOW )
                //so bump the "option" count; in this example it is limited to 16 values (0x0 ..0xf)
                option = (option + 1) & 0xf;

Thank to Blackfin and MorganS for reply.
i will try with sample code of Blackfin