dot3k LEDbar KIT effect


#1

I don’t know if this is the right place or not so please rove accordingly.

I’m still learning how to write in python so I thought I’d try a kind of KIT (the car in Knight Rider) effect (the lights behind the grill) on the LED bar. The script I’ve written has managed to get it to go back and forth. Is there a way I can just repeat the same part until I say stop.


#2

Hi!

In Python you use while True: to loop something until you hit ctrl-c on the keyboard. So, your code would look something like this:

while True:
    your code 1
    your code 2
    your code 3

Note that the indentation is important. Indent only the code you want looped 4 spaces. After that, resume to your normal no indentation.

Hope this helps!


#3

thanks, I didn’t think it would be that simple


#4

is there a way to make 2 LEDs come on and go off at the same time?


#5

Hi!

I’m unfamiliar with the dot3k, but I can give you the basic structure of the code. At the very beginning, type
import time. Then, find the spot where you would like to turn on the LEDs and type something like this

led1.on()
led2.on()
time.sleep('a value in seconds')
led1.off()
led2.off()

Again, replace the led1/2.on/off() commands with the appropriate ones for the dot3k.


#6

Oh yeah, I’m already using import time for a delay. I just had to swap them around. Thanks again