Created
August 13, 2020 18:34
-
-
Save jbfink/18f3747db9c54edd7adf287a31975501 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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