my idea is parking sensor
i was inspired by EOweek activity (waving hand)
i learn about how to use the ultrasonic sensor , it was great to try it again as an approach to my project idea
tinkercad
jumpers
breadboard
arduino
buzzer
ultrasonic sensor
led
220 ohm resistor
circuit simulation
components needed :
breadboard
arduino
led
220 ohm resistor
ultrasonic sensor
buzzer
jumpers
my park sensor with details HERE ...
the idea of the park sensor is making visual alarm and sound when any body get near to the ultrasonic sensor , the input is the distance and , the outputs are light & sound
1- connect the arduino to the breadboard
possitive by red wire to the 5v
negative by black wire to the GND
2-connect the LED and 220 ohm resistor
possitive by yellow wire to the pin no.3
negative leg with the resistor then connect to the negative row of the breadboard
3-connect the buzzer
possitive leg with jumper wire to the pin no.7
connect negative leg to the negative row of the breadboard
4- connect the ultrasonic sensor to the breadboard
possitive by red wire to the possitive row of the breadboard
negative by black wire to the negative row of the breadboard
coding
1- from output choose (print to serial monitor) to enable me to see values of distance
2- from input choose ( read ultrasonic distance sensor )
3- i set the pins as it is in the breadboard 4& 5
4- from math choose comparison block then duplicate the previous block to it
5-i set the distance to greater than 10 cm
6- i add the green block to if block from control
7-from output choose set pin 3 to high (to make the light on when the distance is greater than 10 cm )
8-from output choose set pin 3 to high (to make the buzzer on when the distance is greater than 10 cm )
9- wait 100 m.s then set them low to make the effect of blinking
in order to blink faster if the distance is less than 10cm i repeat all blocks again from 2to9 and change the distance to less than 10cm
10- l repeat the blocks from2 to 8 and set the distance more than 20 and set the pins low in order to make light and sound off if the body go further
coding blocks
1- connect the arduino to the breadboard
possitive by red wire to the 5v
negative by black wire to the GND
2-connect the LED and resistor
possitive by yellow wire to the pin no.3
negative leg with the resistor then connect to the negative row of the breadboard
3-connect the buzzer
possitive leg with jumper wire to the pin no.7
connect negative leg to the negative row of the breadboard
4- connect the ultrasonic sensor with
positive red wire
negative black wire
trigger gray wire
eco white wire
5- connect the wires to the arduino
trigger gray wire to pin4
eco white wire to pin 5
6-connect the wires to the breadboard
positive red wire to the possitive line
negative black wire to the negative line
7- copy the coding text from tinkercad
8- paste it in aurduino and uploade
now i'm ready to simulate ....
// C++ code
//
int set_input = 0;
int input = 0;
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()
{
Serial.begin(9600);
pinMode(3, OUTPUT);
pinMode(7, OUTPUT);
}
void loop()
{
Serial.println(0.01723 * readUltrasonicDistance(4, 5));
if (0.01723 * readUltrasonicDistance(4, 5) >= 5) {
digitalWrite(3, HIGH);
digitalWrite(7, HIGH);
delay(100); // Wait for 100 millisecond(s)
digitalWrite(3, LOW);
digitalWrite(7, LOW);
delay(100); // Wait for 100 millisecond(s)
}
if (0.01723 * readUltrasonicDistance(4, 5) < 5) {
digitalWrite(3, HIGH);
digitalWrite(7, HIGH);
delay(10); // Wait for 10 millisecond(s)
digitalWrite(3, LOW);
digitalWrite(7, LOW);
delay(10); // Wait for 10 millisecond(s)
}
if (0.01723 * readUltrasonicDistance(4, 5) > 10) {
digitalWrite(3, LOW);
digitalWrite(7, LOW);
}
}
Title of Media
my first challenge was how to simulate the distance by moving ball , i tried to set the serial monitor it helps me to check it well
i use try and eror
2nd challenge was when i tried the real circuit , the sensor was active all times because there are many things around it in my room , i decrease the distances to half values it works better
sreial monitor
Title of Media
this week i think i can imagin how my project will work and what sensors i will need
Title of Media
Title of Media