Hi all,
I am trying to create a pomodoro timer using a picoW and the Pico Unicorn Pack. I found some code that I could use to achieve this from the raspberry site but every time I input and run it I get this error message:
MPY: soft reboot
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
AttributeError: 'module' object has no attribute 'init'
Trawling the Internet and trying to work this out I cannot find what the error refers to in the code, which I have pasted below. Can anyone help? I know it's to do with this line "picounicorn.init()" but it seems correct from what I can find on the Internet. Sorry I am very new to coding and wanted to try to see if it is something I could build on to do bigger projects later.
import math
import utime
import picounicorn
picounicorn.init()
def pomocycle():
# Set up our variables
r = 255
g = 0
column = 15
row = 6
phase = "work"
multiplier = 134
# Start counting down
while not(picounicorn.is_pressed(picounicorn.BUTTON_Y)):
# Illuminate every LED on the board
for x in range(16):
for y in range(7):
picounicorn.set_pixel(x, y, r, g, 0)
# Extinguish LEDs one by one
while row > -1:
while column > -1:
for x in range(multiplier):
if not(picounicorn.is_pressed(picounicorn.BUTTON_Y)):
utime.sleep(0.1)
else:
break
picounicorn.set_pixel(column, row, 0, 0, 0)
column -= 1
column = 15
row -= 1
row = 6
# No more LEDs? Switch from work to rest and vice versa
if phase == "work":
phase = "rest"
multiplier = 27
r = 0
g = 255
elif phase == "rest":
phase = "work"
multiplier = 134
r = 255
g = 0
pass
# Clear the display
for x in range(16):
for y in range(7):
picounicorn.set_pixel(x, y, 0, 0, 0)
while True:
while picounicorn.is_pressed(picounicorn.BUTTON_X):
pomocycle()
I am trying to create a pomodoro timer using a picoW and the Pico Unicorn Pack. I found some code that I could use to achieve this from the raspberry site but every time I input and run it I get this error message:
MPY: soft reboot
Traceback (most recent call last):
File "<stdin>", line 5, in <module>
AttributeError: 'module' object has no attribute 'init'
Trawling the Internet and trying to work this out I cannot find what the error refers to in the code, which I have pasted below. Can anyone help? I know it's to do with this line "picounicorn.init()" but it seems correct from what I can find on the Internet. Sorry I am very new to coding and wanted to try to see if it is something I could build on to do bigger projects later.
import math
import utime
import picounicorn
picounicorn.init()
def pomocycle():
# Set up our variables
r = 255
g = 0
column = 15
row = 6
phase = "work"
multiplier = 134
# Start counting down
while not(picounicorn.is_pressed(picounicorn.BUTTON_Y)):
# Illuminate every LED on the board
for x in range(16):
for y in range(7):
picounicorn.set_pixel(x, y, r, g, 0)
# Extinguish LEDs one by one
while row > -1:
while column > -1:
for x in range(multiplier):
if not(picounicorn.is_pressed(picounicorn.BUTTON_Y)):
utime.sleep(0.1)
else:
break
picounicorn.set_pixel(column, row, 0, 0, 0)
column -= 1
column = 15
row -= 1
row = 6
# No more LEDs? Switch from work to rest and vice versa
if phase == "work":
phase = "rest"
multiplier = 27
r = 0
g = 255
elif phase == "rest":
phase = "work"
multiplier = 134
r = 255
g = 0
pass
# Clear the display
for x in range(16):
for y in range(7):
picounicorn.set_pixel(x, y, 0, 0, 0)
while True:
while picounicorn.is_pressed(picounicorn.BUTTON_X):
pomocycle()
Statistics: Posted by Clarkeyboy24 — Wed Mar 13, 2024 4:38 pm — Replies 0 — Views 4