Question: Hello, I need to create a mini puzzle game using python, a raspberry pi, and a breadboard. The puzzle will prompt the user to press

Hello,

I need to create a mini puzzle game using python, a raspberry pi, and a breadboard. The puzzle will prompt the user to press 5 buttons on a breadboard in a certain order. If they press the buttons in the right order, they are told they are correct. If they press the buttons in the wrong order, they are told they are incorrect. The order can be set to a specifc order and does not need to change. Here is what I have so far:

import RPi.GPIO as GPIO

import time

GPIO.setmode(GPIO.BCM) GPIO.setup(18, GPIO.IN, pull_up_down=GPIO.PUD_UP)

while True: input_state = GPIO.input(18)

if input_state == False: print('Button 1 Pressed')

time.sleep(0.2)

GPIO.setup(17, GPIO.IN, pull_up_down=GPIO.PUD_UP)

while True: input_state = GPIO.input(17)

if input_state == False: print('Button 2 Pressed')

time.sleep(0.2)

GPIO.setup(23, GPIO.IN, pull_up_down=GPIO.PUD_UP)

while True: input_state = GPIO.input(23)

if input_state == False: print('Button 3 Pressed')

time.sleep(0.2)

GPIO.setup(24, GPIO.IN, pull_up_down=GPIO.PUD_UP)

while True: input_state = GPIO.input(24)

if input_state == False: print('Button 4 Pressed')

time.sleep(0.2)

GPIO.setup(12, GPIO.IN, pull_up_down=GPIO.PUD_UP)

while True: input_state = GPIO.input(12)

if input_state == False: print('Button 5 Pressed')

time.sleep(0.2)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!