Skip to content

Instantly share code, notes, and snippets.

@jbfink
Created August 13, 2020 18:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jbfink/18f3747db9c54edd7adf287a31975501 to your computer and use it in GitHub Desktop.
Save jbfink/18f3747db9c54edd7adf287a31975501 to your computer and use it in GitHub Desktop.
import board
import random
import time
from digitalio import DigitalInOut, Direction
PRESS3 = DigitalInOut(board.BUTTON_3)
PRESS_JOYSTICK = DigitalInOut(board.SWITCH_PRESS)
def light():
if board.DISPLAY.brightness == 1:
board.DISPLAY.brightness = 0
else:
board.DISPLAY.brightness = 1
def coinflip():
choice = random.choice(["Heads","Tails"])
print(choice)
while True:
if PRESS3.value == False:
time.sleep(0.3)
coinflip()
if PRESS_JOYSTICK.value == False:
time.sleep(0.3)
light()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment