Exemplo n.º 1
0
from cockle import randint
first = (randint(255), randint(255), randint(255))
second = (randint(255), randint(255), randint(255))

# found to be stable with segment strip driven by 74HCT245 Quad Buffer (logic level convertor)

from neoSPI import NeoPixel
from machine import SPI, disable_irq, enable_irq
import time
spi = SPI(1, baudrate=3200000)
pixels = NeoPixel(spi, 12)

while True:
    sec = time.time()
    first = (255, 0, 0)
    second = (0, 255, 0)
    while (time.time() - sec) < 5:
        pixels[:6] = first
        pixels[6:] = second
        state = disable_irq()
        pixels.write()
        enable_irq(state)
Exemplo n.º 2
0
letter_e = [0, 1, 2, 7, 8, 9, 14, 15]
letter_x = [3, 5, 10, 12]
letter_c = [0, 1, 2, 9, 14, 15]
letter_h = [2, 6, 7, 8, 9, 13]
letter_a = [0, 1, 2, 6, 7, 8, 9, 13]
letter_n = [2, 3, 6, 9, 12, 13]
letter_g = [0, 1, 2, 8, 9, 13, 14, 15]

word = [
    letter_e,
    letter_x,
    letter_c,
    letter_h,
    letter_a,
    letter_n,
    letter_g,
    letter_e,
]

while True:
    color = [randint(256), randint(256), randint(256)]
    for letter in word:
        clearPixels()
        for segment in letter:
            setSequence(map[segment], color, show=False)
        showPixels()
        sleep(0.3)
        clearPixels()
        sleep(0.05)
    sleep(2)
Exemplo n.º 3
0
'''
Final distribution: [10300, 10069, 10186, 10341, 10128, 10161, 9554, 9776, 9810, 9675]
Runtime for 100000 numbers was 148 seconds
Final distribution: [10235, 10014, 10099, 10182, 9779, 9861, 9830]
Runtime for 70000 numbers was 98 seconds
Final distribution: [9975, 10025]
Runtime for 20000 numbers was 27 seconds
'''
from cockle import randint
from time import time
start = time()
bound = 2
count = 0
target = bound * 10000
l = [0 for i in range(bound)]
while count < target:
    l[randint(0, bound)] += 1
    if count & 1023 == 1023:
        print(l)
    count += 1
end = time()
print("Final distribution: {}".format(l))
print("Runtime for {} numbers was {} seconds".format(target, end - start))