-
-
Save davipo/50cdf1442af9d7ff5f74 to your computer and use it in GitHub Desktop.
Dice Roll
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
#Function to roll dice | |
def dice(): | |
roll = randint(1,6) | |
print(roll) | |
leds = [d1, d2, d3, d4, d5, d6] | |
# turn on the number of LEDs specified by roll | |
for led in leds[:roll]: | |
GPIO.output(led, 1) | |
sleep(3) | |
# turn them off | |
for led in leds[:roll]: | |
GPIO.output(led, 0) |
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
#Function to roll dice | |
def dice(): | |
roll = randint(1,6) | |
print(roll) | |
leds = [d1, d2, d3, d4, d5, d6] | |
# turn on the number of LEDs specified by roll | |
for led in leds[:roll]: | |
GPIO.output(led, 1) | |
sleep(3) | |
# turn them off | |
for led in leds[:roll]: | |
GPIO.output(led, 0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
diceRoll.py is the same code with tabs changed to 4 spaces for good Python style.