Sep-19-2019, 04:27 PM
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.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
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 |