Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management Systems Designing And Building Business Applications

Authors: Gerald V. Post

1st Edition

0072898933, 978-0072898934

More Books

Students also viewed these Databases questions