How to make LED chase/running effect?

Hi everyone, I need help creating a led chase effect with 4 lights that runs without stopping, can you guys help with the yaml for that, each LED should use it’s own pin.

Something like this bellow…

Did you get one LED hooked up and switchable?

I would have thought you would just do that 4 times.

Then maybe set up another switch with say a repeat
or while action, with delays that cycle through the LEDs.

1 Like

Hi Mahko, my problem isn’t really creating the the effect, it is how to make it repeat infinitely.

You can use the interval: component to achieve infinitely

light:
  - platform: binary
    output: led_1_o
    id: led_1
  - platform: binary
    output: led_2_o
    id: led_2
  - platform: binary
    output: led_3_o
    id: led_3
  - platform: binary
    output: led_4_o
    id: led_4

output:
  - id: led_1_o
    platform: gpio
    pin: GPIO16
  - id: led_2_o
    platform: gpio
    pin: GPIO17
  - id: led_3_o
    platform: gpio
    pin: GPIO18
  - id: led_4_o
    platform: gpio
    pin: GPIO19


interval:
  - interval: 200ms
    then:
      - lambda: !lambda |-
          static int led_nr=1;
          
          switch (led_nr) {
            case 1:
            { 
              auto call = id(led_1).turn_on();
              call.perform();
              call = id(led_4).turn_off();
              call.perform();
              break;
            }

            case 2:
            { 
              auto call = id(led_2).turn_on();
              call.perform();
              call = id(led_1).turn_off();
              call.perform();
              break;
            }

            case 3:
            { 
              auto call = id(led_3).turn_on();
              call.perform();
              call = id(led_2).turn_off();
              call.perform();
              break;
            }

            case 4:
            { 
              auto call = id(led_4).turn_on();
              call.perform();
              call = id(led_3).turn_off();
              call.perform();
              break;
            }

            default:
              break;
          }

          led_nr += 1;
          if (led_nr == 5) {
              led_nr = 1;
          }
2 Likes

Thank you that helped a lot, I am using this to make a stepper run without stopping,
Do you know how to achieve the same effect but using the stepper component?

No, I never used that component. As far as I know that component is used to control a stepper motor DRIVER and not different output pins.