This is an old revision of the document!
Carlos Javier del Nero Castón
1. Is it within range to warn? 1.Yes 1. Trigger visual and audible alarm 2. Continue 2. No 1. Continue
The algorithm of the visual and audible warning system would be as follows.
1. Are you in the green zone?
1. Yes 1. Turn on green LED 2. Emit sound 1 3. Exit 2. No 1. Continue
2. Are you in the yellow zone?
1. Yes 1. Turn on yellow LED 2. Sound 2 3. Exit 2. No 1. Continue
3. Are you in the red zone?
1. Yes 1. Turn on red LED 2. Emit sound 2 3. Exit 2. No 1. Continue
From the two previous algorithms, we deduce that we will need several decision thresholds, one for each situation.
To measure distances with Arduino we can do it in different ways. There is the infrared sensor, which uses the properties of light to calculate distance, and the Arduino ultrasonic sensor uses the propagation properties of sound to measure distances. More specifically it uses ultrasound. This type of sound waves are above the spectrum audible to humans.
The operation is very simple. The sensor sends an ultrasonic wave through the trigger, it bounces off the object and the receiver or echo detects the wave. By knowing how long the wave has taken to travel, we can find out the distance.
To correctly simulate the distance sensor we are going to use an Arduino buzzer. These components use piezoelectricity, a physical phenomenon that affects certain crystals (quartz is the most common). When a crystal of this type is subjected to piezoelectricity, it deforms and vibrates. If we get that vibration to have a frequency within the audible spectrum, we get a sound.
Finally, we incorporate the visual alert system for the Arduino ultrasonic sensor. This allows us to visualise whether we are near or far from an obstacle.
With 3 LEDs (green, yellow and red).
Where we will connect the components.
To make the connections.
Of 220 Ω
ELECTRIC SCHEMATIC
Through the ultrasonic sensor we are going to detect the obstacle. We start programming by declaring the variables and constants.
We define the pins for the LEDs, for the ultrasonic sensor and for the Arduino buzzer. Then we declare 4 constants. The first one is the speed of sound converting from metres per second to centimetres per second. We do this by multiplying by 100. The next constants are the decision thresholds we marked earlier.
In the setup function we start the serial monitor and set the pins to the corresponding mode. The LEDs, the Trigger of the ultrasonic sensor and the buzzer are in output mode (OUTPUT). The Echo pin of the ultrasonic sensor is in INPUT mode.
The loop() function contains the code that will be repeated over and over again. This is where we are going to put all our algorithm, the one we have detailed above. I have split this function into several functions to make the code more readable.
The first thing we do is to prepare the ultrasonic sensor. We do this with the function initiateTrigger() which sends a pulse. It starts in the low state for 2 milliseconds, then 10 milliseconds in the high state and finally we put it in the low state. This indicates that the signal will then be sent to be picked up by echo.
Fişierele se încarcă pe wiki folosind facilitatea Add Images or other files. Namespace-ul în care se încarcă fişierele este de tipul :pm:prj20??:c? sau :pm:prj20??:c?:nume_student (dacă este cazul). Exemplu: Dumitru Alin, 331CC → :pm:prj2009:cc:dumitru_alin.
Exemplu de schemă bloc: http://www.robs-projects.com/mp3proj/newplayer.html
- Arduino UNO - Protoboard where we will connect the components - Cables to make the connections - 3 resistors of 220 Ω - 1 green LED - 1 yellow LED - 1 red LED - 1 Arduino ultrasonic sensor (HC-SR04) - 1 buzzer.
===== Jurnal =====
===== Bibliografie/Resurse =====
<note>