10 minutes is not exaggerated but true, the breakdown is about 5 minutes while looking at the sample program that seems to be related, and about 5 minutes to connect the parts and write the code (actually copy and paste), totaling 10 It was about a minute
GrovePi+ Starter Kit GrovePi + Starter Kit is Seeed's [Grove Sensor](http: //: // An expansion board GrovePi that enables you to use www.seeedstudio.com/depot/s/grovefamily.html on your Raspberry Pi, assorted several Grove sensors. It's a set at a reasonable price, so it's a Grove system starter kit for Raspberry Pi users (I can only explain what you can tell from the name ^^;)
In the Review section (P56) of MagPi's Issue 33, [GrovePi + Starter Kit](http://www.dexterindustries.com/GrovePi/ get-started-with-the-grovepi / grove-pi-starter-kit /) was featured in a review book __ If you're a python fan who wants to get started with electronics, it's a great choice __ I was worried. Until then, it's just __ you don't have to worry about electrical connections __ (I'm very grateful to a software shop like me who doesn't like electricity just to not worry about it). I thought, but it seems that it is not so, and you can use the very convenient Cleaver Script.
It was hard to tell which program was the sample of which sensor, but I gradually realized that it was running for the time being. This sounds fun, and you can do anything by just connecting the lines and reading and writing with an Arduino sketch-like syntax. In particular, __LCD is very convenient, and it's as easy as setting the character string you want to display and the color of the backlight __, and it seems that you can pay for what you bought.
Parking Sensor Looking at the parts of the Kit, I felt like I could make the Parking Sensor that appeared on MagPi's issue 31. From here, it took about 10 minutes to complete. Anyway __ it's as easy as you think __ you don't have to think about anything __
Basically it's just RaspberryPi and GrovePi + Starter Kit
The completed image looks like this
I'm sorry ^^; I have an unrelated DHT (digital humidity thermometer, blue guy) in the picture ^^ ;;;; It was easy to send these measurements to M2X in the near future ...
Measure the distance to the parking lot wall with an ultrasonic distance sensor
Probably convenient for parking a car. Actually, I've never had a driver's license, so I'm not familiar with it ...
For the backlight, I tried to add the effect of fade-out by referring to the sample program (copy and paste). In the completed code, it is realized by changing the color of the backlight with a for loop.
The operation of the finished product is like this
I first looked at the code below, it's just a short code that you can see at a glance
The following code is completed by somehow sticking these together. What I'm doing is as simple as turning a loop, measuring the distance, and changing the display according to the distance, but that's because it's full of magic numbers and there aren't enough comments. I think it's the real reason I made it in 10 minutes ...
Completion code
import sys
sys.path.append("/home/pi/GrovePi/Software/Python/grove_rgb_lcd")
import time
from grovepi import *
from grove_rgb_lcd import *
# Connect the Grove Ultrasonic Ranger to digital port D4
# SIG,NC,VCC,GND
#ultrasonic_ranger = 4
ultrasonic_ranger = 2
led_green = 5
led_red = 6
buzzer = 8
pinMode(buzzer,"OUTPUT")
pinMode(led_green,"OUTPUT")
pinMode(led_red,"OUTPUT")
time.sleep(1)
while True:
try:
# Read distance value from Ultrasonic
distance = ultrasonicRead(ultrasonic_ranger)
print distance
dist = int(distance)
if dist > 100:
# non
digitalWrite(led_green,0)
digitalWrite(led_red,0)
setText("distance = "+str(dist))
for c in range(0,255):
setRGB(255-c,255-c,255-c)
time.sleep(.0039)
elif dist > 30:
# green
digitalWrite(led_green,1)
digitalWrite(led_red,0)
setText("distance = "+str(dist))
for c in range(0,255):
setRGB(255-c,255,255-c)
time.sleep(.0039)
else:
# red, buzzer 1sec
digitalWrite(led_green,0)
digitalWrite(led_red,1)
digitalWrite(buzzer,1)
setText("distance = "+str(dist))
for c in range(0,255):
setRGB(255,255-c,255-c)
time.sleep(.0039)
digitalWrite(buzzer,0)
except TypeError:
print "Error"
except IOError:
print "Error"
It's really easy.
I thought that the simplicity of being able to do something like electronic work with this alone was certainly __ ”a great choice” __ as MagPi said.
I feel that the measured value of the distance sensor is a little short. The ultrasonic distance sensor measures the distance by multiplying the speed of sound by the time it takes for the ultrasonic pulse wave to be reflected by the object and return, but the setting value of the speed of sound (a function of temperature and humidity) is a little too fast. It is presumed that (based on a hot and humid place?). Since there is no API to give the temperature and humidity for correction, it seems that correction on the application side is necessary to obtain the accurate distance.
Futur works Using GrovePi + to send dht11 greenhouse sensor readings to m2x in 10 minutes
Recommended Posts