WEEK 7 - Journal
WEEK 7 - Journal
The idea
The idea of this week is an extension to the last week assignment, building a parking sensor whuch read signals from multiple input components and control multiplemultiple output actions
1- Arduino UNO to generate signals
2- Buzzer to generate sound
3- Ultrasonic sensor to detect the distance
4- wires and breadboard to connect the circuit
5-USB A to USB B cable to connect the Arduino with the laptop
6-220 Ohm Resistor for the LEDs connection
7- RGB LED
8- CardBoard
9- glue gun
10- ML35 sensor
Arduino Uno
Buzzer
Breadboard
Wires
RGB LED
220ohm resistor
Glue gun
Ultrasonic sensor
Ultrasonic sensor
datasheet
Card board
LM35 sensor
By using Tinker Cad software, design and test the circuit before implement it physically
Using Arduino IDE, program the Arduino UNO to implement the actions needed
TINKER CAD circuit
ultrasonic sensor + Temp. sensor
Smart devise that sense the distance to help the car to park easily and maintain the temp. of the car motor
In ultrasonic part, when you are going to crash, the sensor start to send signals to the buzzer to help you stop and park easily
at the same time the RGB emit red light to tell you to stop
the second part use a temp. sensor to maintain the temp. of the motor, so you have to take care if the blue light AND the buzzer turned on.
You are Always safe, when the GREEN light is on.
off state
ultrasonic ON state
ML35 ON state
Simulation
Actual circuit
Arduino code
// C++ code
//
long readUltrasonicDistance(int triggerPin, int echoPin)
{
pinMode(triggerPin, OUTPUT); // Clear the trigger
digitalWrite(triggerPin, LOW);
delayMicroseconds(2);
// Sets the trigger pin to HIGH state for 10 microseconds
digitalWrite(triggerPin, HIGH);
delayMicroseconds(10);
digitalWrite(triggerPin, LOW);
pinMode(echoPin, INPUT);
// Reads the echo pin, and returns the sound wave travel time in microseconds
return pulseIn(echoPin, HIGH);
}
void setup()
{
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(A5, INPUT);
}
void loop()
{
if (0.01723 * readUltrasonicDistance(12, 13) <= 20) {
digitalWrite(2, LOW);
digitalWrite(3, LOW);
digitalWrite(4, HIGH);
digitalWrite(5, HIGH);
delay(1000); // Wait for 1000 millisecond
digitalWrite(5, LOW);
delay(1000); // Wait for 1000 millisecond
} else {
digitalWrite(3, HIGH);
digitalWrite(2, LOW);
digitalWrite(4, LOW);
digitalWrite(5, LOW);
}
if (-40 + 0.488155 * (analogRead(A5) - 20) >= 40) {
digitalWrite(2, HIGH);
digitalWrite(3, LOW);
digitalWrite(4, LOW);
digitalWrite(5, HIGH);
delay(250); // Wait for 250 millisecond(s)
digitalWrite(5, LOW);
delay(250); // Wait for 250 millisecond(s)
}
else {
digitalWrite(2, LOW);
digitalWrite(3, HIGH);
digitalWrite(4, LOW);
}
}
After displaying the temp. sensor, the blue light remain and does not return back to the blank color (green)
but after i completed the if statement with "else" the blue light turned of after the effect of heat ended.
Start using Arduino C code to write a full code for the first is a really exciting experience, I learned how to implement the functions using writing instead of BLOCKS, which makes me get deeper with the Arduino concepts to use it on my final project
Arduino C code