John L. Sokol - computer expert, video, compression, information theory and all things cool.
Tuesday, August 14, 2018
Micro:bit getting more resolution on led array
Microbit Gaussian LED bounce
# Add your Python code here. E.g.
from microbit import *
import math
image = Image("90009:"
"12345:"
"56790:"
"02468:"
"90009")
wid = 1.2
#for ctx in range(0, 50):
# for cty in range(0, 50):
xv = 3.3
yv = 4.1
xlim = 5
ylim = 5
ctx = xlim
cty = ylim
while True:
ctx += xv
cty += yv
if ctx > (50-xlim):
xv = -xv
if ctx < xlim :
xv = -xv
if cty > (50-ylim) :
yv = -yv
if cty < ylim :
yv = -yv
tx = ctx / 10 ty = cty / 10 str1 = ""
for x in range(0, 5):
for y in range(0, 5):
pix = int(math.exp( -pow(x-tx,2)/wid )* math.exp( -pow(y-ty,2)/wid ) * 9)
# str1 += str(x+y)
str1 += str(pix) if x < 4:
str1 += ":"
image = Image(str1) display.show(image, delay=0, wait=True, loop=False, clear=False)
#print (str1)
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment