This week's task is to design and program a smart device that perform a certain function by programming Arduino UNO to read signals from multiple input components to control multiple action components using Arduino C (Text Code).
I got the inspiration from my final project , so I decided to build a part of its circuit using the input components (Keypad and push-button) and the action components ( LCD screen and RBG LED)
I used Tinkercad web app to design and simulate my circuit.
Electric circuit components:
Jumper wires
crocodile wires
Arduino UNO
9V adaptor
breadboard
Push button
Keypad
LCD screen
RGB LED
Avometer for troubleshooting.
I used Arduino IDE software to run and upload my code on the Arduino board
Open Tinkercad and click on create tab and select circuit
Use the bar on the right to search for the components
Search for the first component "breadboard" then drag it
Then drag the rest of the components of the circuit
Breadboard
Arduino UNO
Push button
Keypad
LCD screen
RGB LED
The input components are keypad and push button
The action components are I2C LCD screen and RGB LED
I will power the Arduino using 9V adaptor and the 5V from the Arduino to power the circuit.
Wiring the components together is done this way
Prepare all the electric circuit components to build the circuit.
Connect the 5V and GND of Arduino to the breadboard.
Connect the rest of the components
keypad is connected to Arduino pins 2,3,4,5,6,7,8,9
RBG LED is connected to Arduino pins 11,12,13,GND
LCD screen is connected to Arduino pins A4, A5 and breadboard's 5V and GND
Push button is connected to Arduino pin 10 and GND
For a better user experience, I replaced the RBG LED with a buzzer and put it on pin 13
Here's the circuit, now lets get to the coding part
I used Google to find out how some of the components are coded, for instance I used Arduino tutorial website to include the code for keypad then pasted it on Arduino IDE.
I followed "divide and conquer" principle so I wrote the code for the keypad alone and tested it on my serial monitor.
Here's the initial code I adjusted for the keypad:
I tested the code for keypad on the serial monitor and it worked as planned:
Let's now integrate the code we want for the LCD screen with the main code as shown:
Finally, let's integrate the code for the buzzer and push button with the main code as shown:
This is our final code, compile and upload to the Arduino Board.
Upload was successful.
Connect the 9V adaptor.
The circuit is working as intended.
I made an enclosure for my circuit, mounted and fixed it using tape, mounting tape and screw drivers
Here is the final result🎉
A challenge I faced was when I uploaded the code to the Arduino but the buzzer was always ON without pressing the push button and would go OFF when I press it.
So this is how I solved the problem:
I created a new sketch and moved the code for buzzer and push button alone, compiled and uploaded it but the problem was the same
I gave my code a second look:
The push button is typically always in HIGH mode so I had to change the if condition to LOW instead of HIGH.
I changed the if condition to LOW then compiled and uploaded my code.
After uploading the code, the circuit worked perfectly as planned.