This week's assignment is to build and program a smart device using an Arduino UNO which reads a signal from a multiple input components (Sensor, Switch, or variable resistor) to control a multiple actions components (Motor, Buzzer, LED...etc) using TEXT CODE instead of using code blocks.
I chose to implement the second step for my final project idea.
Software:
Arduino IDE: To write the codes responsible for programming Arduino compatible boards.
TINKERCAD (website): to predict and test the output of your circuits before implementing them in real life
*TinkerCad is a simple website that provides the feature of simulating electronic circuits., as well as provide explanations to some of the wiring problems that result in damaging the components in your circuit during simulation (i.e. if the current passing through a component is larger than what it can handle, etc.)
Electronics components
3 Resistor (220 Ω)
RGB LED Light
LM35 Temperature sensor
Piezo Buzzer
Breadboard
Arduino UNO Board
jumper wires (per need)
Explaining the idea:
As mentioned before, the temperature sensor should senes the temperature variables and indicates them in colors stages (that have been mentioned).
The second step of my final project: is to use a sound alert that alerts you using a buzzer when your cup temperature reaches a certain degree and a pushbutton to stop the buzzer as a sign that you have heard the alarm.
Simulating the circut on Tinkercad
The circuit design is similar to the last week, temperature sensor (as an input component) to sense the temperature variables, and the LED light (as an output component) should indicate these variables with color changes, a Piezo Buzzer (as an output component) will alerts you when the temperature reaches a certain degree, and a pushbutton (as an input component) stops the buzzer sound.
I connected the temperature sensor and the RGB LED the same way in the previous week, then I connected the buzzer and the pushbutton.
Note: In TinkerCad simulation, there isn't LM35 temperature sensor, so I used TMP36 instead.
TinkerCad simulation
Coding design:
Explaining the code:
First: I defined the component I used and which pins they are connected to on the Arduino.
Second: in the Void Setup sekchen, I wrote the processes I want to be run for once.
Third: Void loop sekchen:
firs in the loop sekchen; reading the temperature and The process of changing temperatures from the Fernheit to the Celesius, and printing this to the serial monitor.
The same color indication.
The first step is: If the temperature is below 15c, The LED's color will be BLUE and indicates that the cup is very cold.
Second: If the temperature is below 20c, The LED's color will be CYAN which indicates that the cup is getting cold.
If the temperature is below 25c, The LED's color will be GREEN which indicates that the cup is at the perfect temperature.
If the temperature is below 30c, The LED's color will be MAGENTA which indicates that the cup is warm close to hot.
Finally: If the temperature is above 30c, The LED's color is RED which indicates that the cup is burning hot. and the buzzer pin will be set to HIGH.
If the push button was pushed means that the pushbutton pin is set to HIGH the buzzer should stop means that the buzzer pin is set to LOW.
Finally, connecting the Arduino to the laptop and Uploading the code to the Arduino board and test it.
Wiring the circuit on the physical breadboard and connected it to the Arduino UNO board.
I connected each RGB LED's color with a current limiting resistance,
connect each of them to a different Arduino pin. (red goes to pin1, blue goes to pin2, green goes to pin3)
I connected LM35 to the breadboard
then I connected it to an analog pin (A0) on the Arduino board
I connected the buzzer's negative side to the common GND, the positive side is connected to pin 5 on the Arduino.
one side of the push button is connected to the common GND, and the other side of the push button is connected to pin 6 on the Arduino.
then I connected them to pins on the Arduino board (pin 5,6)
The whole circuit
Finally, connected them all to a common GND and VCC from the Arduino.
For the enclosure I used
Cardboard
Exacto knife& Ruler
Tap
Pencil&Paper
I used cardboard for the enclosure, I cut out all the main parts two circles and rectangle to make the rectangle round, then I taped the bottom circle and the rectangle together.
also I cut out the pushbutton and LED place.
I taped the breadboard inside the enclosure.
I built the wiring circuit
finally, I assembled them.
color indications
final implementation
(buzzer alarm and pushbutton stop 1:10)
serial monitor readings
Wiring electronic components and coding are a little confusing, especially 'cause I am not previously familiar with the specifications of some components, as I failed to complete the Hands-on and Midweek activities in the right way, also it was difficult for me to troubleshoot the assignment :(.
didn't know how to arrange the code and what should come first ...etc.
a lot of Syntex wrongs in the code.
didn't know how to connect the push button to the buzzer at first, then I try different ways in TinkerCad till I figure it out.
because of the wrong arrangement of codes lines (in the buzzer-push buttton sekchen), the reason why the sound of the buzzer did not come out
As usual, I get stuck in-circuit wiring and coding XD, in the EOWeek session, AHMED HAMMAD and I were in one group and he explained the whole circuit wiring and coding process to me, really, he helped me a lot understanding.
also, I had a problem uploading a library to IDE, Mr. Sherif help me with it.
This assignment aims to learn how to control multiple components by Arduino board through multiple input. This gives you more control over the components in your circuit and the ability to program each one of them individually to do certain tasks, That will help me controling my final project components as I need.
Assignment file