Skip to content
Snippets Groups Projects
Commit eb51118d authored by hc3g21's avatar hc3g21
Browse files

Upload New File

parents
No related branches found
No related tags found
No related merge requests found
from machine import Timer, Pin
import math
import random
import utime
from pimoroni import Button
from picographics import PicoGraphics, DISPLAY_PICO_DISPLAY, PEN_P4
timer_count = 0 # global variable
# We're only using a few colours so we can use a 4 bit/16 colour palette and save RAM!
display = PicoGraphics(display=DISPLAY_PICO_DISPLAY, pen_type=PEN_P4, rotate=0)
display.set_backlight(0.5)
display.set_font("bitmap8")
button_a = Button(12)
button_b = Button(13)
button_x = Button(14)
button_y = Button(15)
lastButton = button_y
WHITE = display.create_pen(255, 255, 255)
BLACK = display.create_pen(0, 0, 0)
CYAN = display.create_pen(0, 255, 255)
MAGENTA = display.create_pen(255, 0, 255)
YELLOW = display.create_pen(255, 255, 0)
GREEN = display.create_pen(0, 255, 0)
def interruption_handler(pin):
global timer_count
timer_count += 1
# sets up a handy function we can call to clear the screen
def clear():
display.set_pen(BLACK)
display.clear()
display.update()
# set up
clear()
while True:
if button_a.read():
lastButton = button_a
timer_count = 0
if button_b.read():
lastButton = button_b
if button_x.read():
lastButton = button_b
if button_y.read():
lastButton = button_b
if lastButton == button_a:
utime.sleep(1)
timer_count += 1
print(timer_count)
clear()
display.set_pen(WHITE) # change the pen colour
#display.text(str(round(timer_count/20)), 10, 10, 240, 4) # display some text on the screen
display.text(str(timer_count),10,10,240,4)
display.update()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment