The assignment for this week is to build and program a smart circuit using an Arduino UNO to read signals from multiple input components to control multiple action components using Arduino C (Text Code) .
Inspiration
It is thr lighting of LEDs in a random sequence, then you should remember the sequence to win the game.
here I found my inspiration.
Software
Arduino IDE to upload code to arduino boards.
Components
Arduino Uno to control the circuit.
Breadboard to connect all components.
Jumper wires for connection.
Buttons to connect two points in a circuit when you press them.
Leds to produce light.
Buzzer to produce audio signal.
330ohm Resistors to limit the current.
LCD & I2C Module to display text messages on the screen.
potentiometer to get variable inputs.
Materials & Tools
Cardboard for enclosure of the electronic components.
Scissors to cut cardboard.
Glue gun for assembly.
Circuit Diagram
Inputs & Outputs
First, The player chooses the difficult level value from 3 to 30 using the potentiometer.
The player presses the start button when he is ready.
The game starts to light on a number of LEDs equal to the difficulty level in a random sequence.
The player should remember the sequence as possible as he can remember.
Then the player enters the buttons in the same sequence as the LEDs sequence.
The Arduino checks if the inputs are correct or not.
Designing Process
Wiring the circuit as the diagram above.
Connect LEDs serious to resistors 330ohm to limit the current.
Divide code into parts like function to initialize the game, function to generate the sequence, function to read inputs, function to check the inputs then print if win or lost the game.
Here is the logic of the code.
To print welcome message for first time.
Wait until the player is ready, read the difficulty level.
To initiate the variables before playing.
To generate the random sequence of the leds and light them.
To check when the player push the button then read it.
To compare the inputs values and check if they are right or wrong.
To print if player win the game or not.
The final sequence of the code after dividing them into parts.
Global variables and libraries for the game.
The setup of the code to give the pins its direction mode.
Memory Game testing
Design Implementation
Test the components { led, Resistors, potentiometer, buzzer, LCD, Push button, Jumpers } before starting.
Connect the components together in the diagram above.
Connect led to resistor 330ohm series.
Connect buttons to Arduino and ground as we use input pull-up mode.
Digging suitable vacuums in the carton to enter the components.
Fix the Arduino and mini breadboard in the base to be stable all time.
Digging a suitable vacuum to enter the adaptor 5v cable.
Test the integration of the circuit after each step.
Final Result
Software problems
I learned how to build an organized, logical and smooth Arduino code.
The prototype is not very different from the Design, as it needs to measure dimensions first and determine its plan and a logical and arranged path before starting.