This week's assignment is to Build and Program a smart device with multiple input components resistor) to control multiple action components using Arduino C (Text Code).
this time i didn`t have any idea to solve personal problem but i started searching and i found an idea to make a smart todo list and it was so cool for me i just tweaked a bit in it from the main one.
it consists of 3 tasks, after completing each task the user will press the pushbutton next to the task he finished an LED will light and a sentence will appear on LCD except for the last task it works with LDR instead of push button.
pressing button 1 ➡️ green light➡️ WELL DONE.
pressing button 2 ➡️ green light➡️ ALMOST THERE.
LDR get light➡️ green light➡️ 3AAAASH.
I used TINKERCAD software to simulate my circuit before implementing it.
and Arduino IDE software to write my circuit Arduino C text
Materials
Prototype Closure Materials
5 card board parts (20*13) cm for the sides & bottom. 1 part (15*15) cm for the top.
glue stick
cutter
ruler.
Electric Components
push buttons.
LEDs
LDR sensor
ARDUINO UNO
LCD screen (16*2)
jumpers
crocodiles
The ideal objective is a smart todo list When the user finishes the first task he will press the first button, the LED will light up and the screen write" WELL DONE", When he finishes the second task he will make as the first task but the screen will write "ALMOST THERE" the last step the LRD will be instead of the push button and covered with the third task paper when the user finishes it he will remove the paper so the sensor will receive light, the led will light up and the screen writes "3aaaash".
First of all, I chose what kind of inputs and outputs I wanted so the final result was that my INPUTS would be: LDR sensors & pushbuttons. OUTPUTS would be LEDs & LCD.
Wiring diagram for the circuit on TinkerCad software.
Organized randomness :")
After that I started by writing down & drawing how I wanted my project to be as I discovered that`s the perfect way for my brain to work with.
The last step in this phase was the cardboard cutting with customized components places and dimensions.
Implementing components & Connections
ARDUINO 5V ➡️+VE RAIL (BREAD BOARD)
LEDs
first led ➡️ pin ~5
second led ➡️ pin ~6
third led ➡️ pin ~7
From each led cathode (the short -ve side), a resistor is connected between it and the -ve rail on the breadboard.
pushbuttons
first one (leg 1) ➡️ -ve rail
first one (leg2) ➡️ pin ~8
second one (leg1) ➡️ -ve rail
second one (leg2)➡️ pin~9
LCD
SCL ➡️A5 (on ARDUINO)
SDA ➡️ A4 (on ARDUINO)
VCC ➡️+ve rail
GND ➡️-ve rail
LDR Sensor
VCC➡️+ve rail
GND➡️GND (ARDUINO)
DO➡️~2(ARDUINO)
Text Code
Before Void Setup
Before writing any code (orders) first i define the component's status before Void setup to preserve a place called x on the ARDUINO memory.
So I wrote all the pins and their components I connected before in the form of integers (int).
For the LCD I installed its library and included its defining code which is written in rows (and 9,10,11) and changed the digits in row 11 to fit the LCD I used which is (16,2) for the number of digits and rows.
And for the LRD I define it on DO pin as this is what I connected it to pin 2 on Arduino.
Make sure that the brackets, symbols & semicolons are in their places with the right number.
Void Setup
I am supposed to write any action I want to repeat only once Also it is preferable to define the outputs & inputs here so I don`t have to define it again in void setup and to be easy for the Arduino to read.
My outputs in this circuit are 3 LEDs (1,2,3) and an LCD screen.
My inputs are 2 push buttons and an LRD sensor.
Void Loop
For any order that I want to be repeated through the process I wrote it under the void loop.
I used the if else condition to make the buttons link with the LCD and LED.
what do I want to achieve?
When the user presses the button an LED will light up and a sentence (well done or almost there) appear on the LCD.
For the sensor part when the sensor is not receiving light the LED doesn`t light else: the LED is working and (3aaaash) appears on the screen.
so for the first step, when I press the button (LOW) the LED will light up (HIGH) and the LCD will write a certain sentence ELSE (if other thing happens) The LED will not light up, with the same concept on the third LED but instead of the button I used LRD, when it receive light the LED will light up and LCD will write the final sentence.
The device was wired and tested with an actual Arduino Board
Todo List Enclosure
Final Product Functional
During coding I faced some errors:
-I wrote PB1 AND PB2 to refer to push buttons but that was wrong as the instructor told me that there is something on the software itself that has the same name so I changed it to the button.
-The brackets & semicolon are things that I usually write wrong or not in the supposed place but with practicing and repeating it became better Also I searched a lot about how to write any code and checked on it also i forgot which pin to connect with Arduino in LDR and this link was so useful for me in both challenges
arduinogetstarted.com/tutorials/arduino-ldr-module#google_vignette
Connection challenges:
-Connecting in the wrong way or a jumper in the wrong pin happened but with trial and error and revising each and every step it worked!