Assignment Objective:
This week's assignment was about making more complex smart devices using Arduino; by combining more than one input component to control more than one output component
Idea:
As the final project week is getting closer, I decided to make a device that utilize most of the input and output components in my final project, to get more comfortable with them. So, I choose to make a simple portable game player, with a game called "speed game", which is about answering 19 questions very fast to win the game
Electronics:
1- Arduino UNO
2- small Breadboard
3- IR sensor
4- Jumper wires
5- LCD 16 x 2 display with I2c module
6- Buzzer
7- 4x 3 Keypad
8- Cardboard
Software:
1- Arduino IDE (for writing and uploading the C++ code to the Arduino board)
2- TinkerCad and Microsoft power point (for drawing the wiring diagram)
IR sensor
4 x 3 Keypad
Input components:
1- the 4 x 3 Keypad to enter the answers
2- the IR sensor to begin the game once you put your hand in front of it, which make it a smarter game play
Output components:
1- the LCD display for displaying the game
2- The buzzer for giving the wining and losing sound effects
Circuit design
Wiring
1- 4 x 3 Keypad:
it has 7 pins, 4 for the rows and 3 for the columns and they are wired as shown in the figure
3- the LCD display:
the LCD is connected to an I2C module to make more convenient wiring with the Arduino and it is wired as shown in the figure above
4- The Buzzer:
it has two legs; one is connected to an output pen (analog output), and the other is connected to the VCC pin
Code
1- libraries:
I imported three libraries:
LiquidCrystal_I2C library, for controlling the LCD display
Keypad library, for controlling the keypad
chrono library, for giving stopwatch functionality in a simple way
2- pseudo code
1- creating two arrays, one for saving the questions (of type string) and the other for saving the corresponding answers (of type char)
2- looping over the questions array and display them on the LCD display
3- checking for the player input and give a 3 seconds time interval for answering the question (using chrono instance)
4- compare the player input with the right answer and if it is correct print on the screen "right" with a specific buzzer tone, and if the answer is wrong print "wrong, try again!"
5- In case of reaching the end of the game or losing, if the player get closer to the IR sensor the game will start all over again
I connected all the component on a big breadboard using jumper wires, I used a cardboard box to integrate the Arduino board and the other components inside it, and I used adhesive tape to fix them on the box
Edit this menu via the Pages tab
Show me
At first I was struggling to find a way for counting time interval for controlling the time for answering the questions, then by some search I found the Chrono library that can give me this functionality
I already made this project to get more comfortable with the LCD and the keypad integration, because they are main components in my final project
Title of Media