Raspberry Pi : Buzzer Game
Our class started to learn about Raspberry Pi and it's component. We are assigned to work in pair. We connect our computer to the Raspberry Pi and use the IDE Thonny to write Python language and develop a simple game. Our game use a buzzer, button, and LED. The rule if you must wait until the buzzer buzz then press the button. The player who press the button first will be the winner and the green light will light up but if you press the button too early the red light will light up instead and you will lose. We use a total of eight GPIO such as two for the buttons, four for the LEDs, one for ground, and one for the buzzer. We connect the ground GPIO to the breadboard and link it with other component. In our python code, we assign different variables for each of the component: LED, button, buzzer. I create a function named result which have 2 parameter, win and player, that will determine whether which player win or lose. Before the buzzing, I make the code repeat sleeping for 0.1 second until it reach the time the buzzer should buzz and at that time the button is checking whether anyone has press it. The result function will run when someone press it and print out whether who lose or win. From this work, I get to learn more library of python such as time, gpiozero, and RPi.GPIO, know how the python work, and have more understanding of python syntax.
ESLOs:
- Strategic Learners
- Innovative Thinker
- Leader of the future