Forever changing colors
-
Just wanted to share this code. This causes the RGB led to slowly change colors, that will never be the same. Using sine/cosine functions with prime numbers in the argument takes care of this. I should test the variable t for a maximum int and then loop backwards, but ok...
import pycom import math pycom.heartbeat(False) t = 0 f = 6.28/10000000. while 1: t+=1 red = 127 + int(127*math.sin(3*f*t)) green = 127 + int(127*math.cos(43*f*t)) blue = 127 + int(127*math.sin(127*f*t)) pycom.rgbled(red*256*256 + green*256 + blue) -
I'm sorry, the 'Insert code block' does not seem to work for me or I use it wrongly...
-
@zappfinger said in Forever changing colors:
I'm sorry, the 'Insert code block' does not seem to work for me or I use it wrongly...
-
@livius Thanks!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login