The idea of the assignment is to build and program a smart circuit using an Arduino UNO which reads a signal from an input component to control an action component using code blocks.
The project idea is a temperature indicator when the temperature get too high or too low the RGB LED and buzzer are functioned to take a specific action.
Link for the video idea: https://youtu.be/I1IYmwJsazQ
Simulating program
Coding program
Used components.
Breadboard
5V adapter
Jumper wires
RGB LED
LM35 temprature sensor
3 Resistors 220 ohm
Arduino uno and its cable
Buzzer
The project is about the danger of the temperature gradient. The temperature sensor is connected with Arduino, RGB led, and a buzzer.
The sensor should read the surrounding temperature. If the temperature is greater than or equal 60, the red led in the rgb should be lighted and the buzzer will produce high sound. If the temperature is between 40 and 60, yellow light is produced. If the temperature is between 40 and 30, green light should ne produced. If the temperature is less than 30, blue light is produced.
The circuit components are RGB LED, buzzer, resistors and temperature sensor.
The 5V and ground pins are connected to the positive and negative nodes on the breadboard. The temperature sensor is connected to the ground, 5V and the signal on pin A3.
The RGB LED is connected to 3 resistors 330 ohm. The 330 ohm resistors is used as the LEDs take voltage less than 5V. In order to protect the LED from burning, the voltage divider method is applied by using resistor to take the exceeded current and voltage.
The RGB red LED is connected to pin 2, blue LED is connected to pin 4 and the green LED is connected to pin 7 and the buzzer is connected to pin 3. All the components ground are collected at common ground on the breadboard, then the common ground is connected via jumper wire to the arduino ground pin.
The circuit on Tinkercad.
The code blocks is listed as follows. The red led in the RGB should be lit and the buzzer should emit a loud sound if the temperature is greater than or equal to 60. Yellow light is produced at temperatures between 40 and 60 degrees. The temperature should produce a green light if it is between 40 and 30. Blue light is created when the temperature is below 30.
The first code block is if conditional to set the function of the temperature sensor. If the temperature greater than 60, the red LED should be lighted up.
Code block of the first function.
Simulating video
The second function is when the temperature between 60 and 40, the yellow LED color is lighted up. if any condition happens all the LEDs should shut down.
The third function is when the temperature between 40 and 30, the green LED color is lighted up. if any condition happens all the LEDs should shut down.
Third function.
The third function is when the temperature between 30 and 25, the blue LED color is lighted up. if any condition happens all the LEDs should shut down.
The last function.
The whole code
I implemented the code on Arduino ide then I checked if there is any syntax errors.
Then I started to implement the circuit on real life and then started to test the code on real life.
The code is listed as follows. The red led in the RGB should be lit and the buzzer should emit a loud sound if the temperature is greater than or equal to 60. Yellow light is produced at temperatures between 40 and 60 degrees. The temperature should produce a green light if it is between 40 and 30. Blue light is created when the temperature is below 30.
Code on Arduino ide.
Code on Arduino ide.
The circuit components are RGB LED, buzzer, resistors and temperature sensor.
The 5V and ground pins are connected to the positive and negative nodes on the breadboard. The temperature sensor is connected to the ground, 5V and the signal on pin A3.
The RGB LED is connected to 3 resistors 330 ohm. The 330 ohm resistors is used as the LEDs take voltage less than 5V. In order to protect the LED from burning, the voltage divider method is applied by using resistor to take the exceeded current and voltage.
The RGB red LED is connected to pin 2, blue LED is connected to pin 4 and the green LED is connected to pin 7 and the buzzer is connected to pin 3. All the components ground are collected at common ground on the breadboard, then the common ground is connected via jumper wire to the arduino ground pin.
The buzzer is also connected to Arduino on PWM pin 3 as the buzzer is analog output so the control of it is easier on PWM pin 3.
Circuit on real life
The sensor at warm temperature
The sensor at hot temperature
The challenge that faced me is that i did not know how to make logical operators on the Arduino coding blocks.
I asked the instructor and she told me how to do it.
From Math commands, I selected the logical operator command
The code blocks without logical operators.
Math commands
The logical operator.
The code block with logical operator.
Second challenge is that the Arduino was not responding to the instructions of the codes. There was a mistake that I put only the working led so in the functioning of the circuit the instructions was not occurred enough.
I added all the leds in the RGB by their modes even if high or low.
Code with mistake.
The right code.
I learnt how to code by code blocks for Arduino. It is an important part as some easy tasks can be done by code blocks to save time.
I learned the concept of mapping between two different ranges.
We built a design for waving hands with manual and automatic mode.
The manual mode is by mapping between the potentiometer range and the servo motor range of angles.
The automatic mode was by waving in front of ultrasonic sensor.
Manual mode with potentiometer
Automatic mode with ultrasonic sensor