The assignment this week was to Measure the analog levels and digital signals in an input device. So our idea was to compare two sensors that would achieve the same job, or solve the same problem. One of them is digital and the other is analog.
We choose to use two sensors that measure:
In order to use the sensors, we first checked the datasheets of the ultrasonic and the infrared sensors.
So the ultrasonic Sensor is considered to be a digital sensor because the microcontroller reads a digital signal from it. How the Ultrasonic mainly works, is by emitting an ultrasound at 40000 Hz which travels through the air and if there is an object or obstacle on its path, it will bounce back to the module. Considering the travel time and the speed of the sound you can calculate the distance.
The HC-SR04 Ultrasonic Module has 4 pins, Ground, VCC, Trig and Echo. The GND and VCC pins of the module need to be connected to the GND and the 5V pins on the Arduino Board respectively. Lastly the trig and echo pins to any Digital I/O pin on the Arduino Board.
In order to generate the ultrasound you need to set the Trig on a High State for 10 µs. That will send out an 8 cycle sonic burst which will travel at the speed sound and it will be received in the Echo pin. The Echo pin will output the time in microseconds the sound wave traveled.
The distance sensor produced by Sharp is a popular and relatively low cost solution for measuring distance. In this test we will use the 2YOA21 model and the characteristics of this sensor are:
The IR distance sensor is connected to a voltage supply, and connected to an analog input to the micro-controller. The microcontroller reads an analog signal, which is technically a value of voltage between 0 and 5V. Based on the value recieved you can deduce the distance between the sensor and an obstacle.
Concerning the Ultrasonic Distance Measuring sensor, you can easily read the information from it on the Serial Monitor, as the signal received from it, is a digital signal, which is converted directly with the help of the existing libraries into the measurements and numbers we need.
However, on the other hand, with the InfraRed Sharp Distance sensor, it is a bit harder to get data from it, because you need to calibrate it first. The IR sensor sends analog data to the Arduino Board, which is technically a variation of the voltage. Thus, what you can read on the serial monitor is a variation in voltage. To convert that into readable information, we should check the values we read with respect to various set distances and calibrate accordingly.
The video represents how the signal is sent and received from and to the arduino board. The signal received at the ECHO signal by the arduino board is a digital signal that represents the variation in distance. On the other hand, the picture represents how the signal is received from the IR sensor. It is mainly a voltage level that variates according to the distance.