Adding Cosinus as utime.sleep variable - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: Adding Cosinus as utime.sleep variable (/thread-21221.html) |
Adding Cosinus as utime.sleep variable - Kreszy - Sep-19-2019 Okay, so I´m having trouble using the Cosinus as variable for ms. I want Cosinus(x) to reach it´s limit at led 11, then go back down again, so I get a lighting effect like the K.I.T.T from Knight Rider, but i really can`t get it to run. Any suggestions to make my code better in general are also welcome, I´m a bloody beginner. import display import leds import utime import color import display import math red=color.Color(255,0, 0) green=color.Color(0, 255, 0) toright=True a=0 b=0 x=math.cos() while True: leds.set(a, red) leds.set(b, green) utime.sleep_ms(x+100) leds.clear() if toright==True: a=a+1 b=a-1 else: a=a-1 b=a+1 if a==10: toright=False if a==0: toright=True |