Python Forum
Adding Cosinus as utime.sleep variable
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Adding Cosinus as utime.sleep variable
#1
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
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there a difference between Python’s time.sleep and win32api.Sleep? phpjunkie 4 1,980 Sep-21-2024, 05:17 PM
Last Post: aakritiintelligence
  Use subprocess.Popen and time.sleep chucky831 2 3,724 Aug-11-2022, 07:53 PM
Last Post: carecavoador
  Adding variable to Python code - media sentiment analysis Marietje 3 4,072 May-25-2021, 05:15 PM
Last Post: jefsummers
  Can you end the Time.sleep function boier96 9 21,425 Jan-16-2021, 10:09 PM
Last Post: Serafim
  time.sleep mtnwinds 4 5,322 May-21-2020, 10:12 AM
Last Post: Larz60+
  time.sleep works erratically, a bug in Python? stipcevic 2 7,128 Jan-21-2020, 09:38 PM
Last Post: Marbelous
  Adding markers to Folium map only adding last element. tantony 0 3,329 Oct-16-2019, 03:28 PM
Last Post: tantony
  How to achieve close to 1ms time.sleep kwekey 1 23,549 Mar-25-2019, 02:52 AM
Last Post: Larz60+
  If error sleep and then try again from there CaptainCsaba 2 4,181 Mar-01-2019, 06:28 AM
Last Post: CaptainCsaba
  time.sleep(...) problem DPaul 3 4,399 Jan-28-2019, 11:40 AM
Last Post: Larz60+

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020
This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.