This Grove - Ultrasonic sensor is a non-contact distance measurement module which
works at 42KHz, suitable for projects that require middle distance measurement.
Specification
Tip
More details about Grove modules please refer to Grove System
Get Started
Connect Serial LCD to D4/D5 pins of Grove - Base Shield and connect Ultrasonic
Ranger to D7.
Download the UltrasonicRanger Library and SerialLCD Library from Github. Since the
are not in origin library of Arduino library files, You need to install them to Arduino
Library. If you don’t know how to install library for Arduino, please refer to the
toturial How to install library
int distance = 0; /* variable to store the distance to obstacles in front */
int blink_interval = 0; /* led delay time */
int8_t bits[4] = {0}; /* array to store the single bits of the value */
/* the setup() method runs once, when the sketch starts */
voidsetup() {
/* Initialize 4-digital display */
tm1637.init();
tm1637.set(BRIGHT_TYPICAL);
/* declare the red_led pin as an OUTPUT */
pinMode(RED_LED, OUTPUT);
}
/* the loop() method runs over and over again */
voidloop() {
distance = ultrasonic.MeasureInCentimeters(); /* read the value from the sensor */
memset(bits, 0, 4); /* reset array when we use it */
for(int i = 3; i >= 0; i--) {
/* get single bits of the analog value */
bits[i] = distance % 10;
distance = distance / 10;
tm1637.display(i, bits[i]); /* display by 4-digital display */
}
delay(100);
}
With Raspberry Pi
Connect Ultrasonic ranger to Port D4 and Run the program below. It will print
distance information on you terminal, as the figure below.
# GrovePi + Grove Ultrasonic Ranger
from grovepi import *
# Connect the Grove Ultrasonic Ranger to digital port D4
# SIG,NC,VCC,GND
ultrasonic_ranger = 4
whileTrue:
try:
# Read distance value from Ultrasonic
print ultrasonicRead(ultrasonic_ranger)
except TypeError:
print "Error"
except IOError:
print "Error"
Run The Program
• Find the path to the file(According to your own path)
cd GrovePi/Software/Python/
• Run Progr am
sudo python grove_ultrasonic.py
Related Projects
If you want to make some awesome projects by Grove - Ultrasonic Ranger, here’s
some projects for reference.
Automatic Water Level Controller
This is an IoT demo make by Arduino and Grove
There are many ways like using a float sensor to determine the water level, or using
probes to detect peak and low level in the tank. How to measure water level without
using probe or contacting with water? yeah there is a way just using a Ultrasonic
sensor, and it is very simple! You can even determine the water depth in the tank by
setting the maximum and minimum level.
Indoor Lightning Cloud
This is an IoT demo maked by Seeeduino and Grove
Make an indoor lightning Cloud, hang it to your ceiling, to make a joke, blast whoever
passing under it, have fun!
The Colour Helix
This is an IoT demo maked by Seeeduino and Grove
Our artist Shihui Wang recently showed me her another amazing work of art: the
Colour Helix. Again with few simple components she presented us the beauty of the
combination of art and electronics.
With a Grove - Ultrasonic Ranger she can magically control the number of illuminated
LEDs inside the Helix by raising or lower her palm in the air.
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.