Distance Measurement using CloudX CloudX
Ultrasonic range finders are fun little modules that measure distance. You can use them to find the distance to an object, or to detect when something is near the sensor like a motion detector. They’re ideal for projects involving navigation, object avoidance, and home security. Because they use sound to measure distance, they work just as well in the dark as they do in the light. The ultrasonic range finder used in this tutorial is the HC-SR04, which can measure distances from 2 cm up to 400 cm with an accuracy of ±3 mm.
The HC-SR04 ultrasonic range finder has four pins: VCC, Trig, Echo, and GND. The VCC pin supplies the power to generate the ultrasonic pulses. The GND pin is connected to ground. The Trigpin is where the CloudX sends the signal to start the ultrasonic pulse. The Echo pin is where the ultrasonic range finder sends the information about the duration of the trip taken by the ultrasonic pulse to the CloudX.
To initiate a distance measurement, we need to send a 5V high signal to the Trig pin for at least 10 µs. When the module receives this signal, it will emit 8 pulses of ultrasonic sound at a frequency of 40 KHz from the transmitting transducer. Then it waits and listens at the receiving transducer for the reflected signal. If an object is within range, the 8 pulses will be reflected back to the sensor. When the pulse hits the receiving transducer, the Echo pin outputs a high voltage signal.
I am going to use the 4 digital tube 7 segment display and the TM16374 library.The requirements for this activity is just a basic parts in cloudx, what we have are:
4 Digit 7- segment diplay
Male - Female jumper wires
The code below supports all the cloudx series, so you can either use cloudx Priscilla, cloudx M633 or any other family of the microcontroller board.
#define trig 5
#define echo 6
#define clk 1
#define dio 2
SegmentTM1637_setting(dio, clk, 5);
distance = Ultrasonic_read(1);