Ultrasonic Sensor

Ultrasonic Sensor Boards

ultrasonic1pinIf you connect a cheap 4 pin Ultrasonic Module as per this diagram, then you can safely connect it to your Pi BUT ONLY WITH THE RESISTORS IN PLACE only need one spare GPIO pin to trigger it and receive the returned pulse

So now you simply use it (assuming connected to pin 23)

Use Sonar23 followed by a wait 1 and then just use the sensor item sonar23 to get the distance measured in cm. Any pin can be used for this purpose and if you had several of them you could broadcast each of them in turn.

Ultra8Alternatively, you can use this syntax which will tell your Raspberry Pi to continuously do a distance check every 1 second and update sensor item Ultra8 with the results without any further need to do another broadcast

MotorPiTx

This board makes it very easy to control Motors and Servos without any extra hardware as well as giving you the ability to switch your Raspberry Pi on and off and power it from AA batteries.

PiGlow

See https://cymplecy.wordpress.com/2013/08/12/scratch-gpio-piglow-support/ for full support info

Compass

CompassYou can plug in a HMC5883L based I2C device and access the magnetic heading value it outputs. Simply set AddOn to Compass and then use the heading sensor value which is updated 4 times every second

BerryClip
https://www.modmypi.com/berry-clip-raspberry-pi-add-on-board?filter_name=berryclip

This really cheap and useful board is an alternative to @drogon LadderBoard.

It has 6 LEDs, a switch and a buzzer

To use it just set the AddOn variable to Berry and then you have easy methods of accessing it

Broadcasts available
[Led1..6] [On/Off/High/Low] e.g broadcast Led1On will make first red led light up

[All] [On/Off/High/Low] e.g broadcast AllOn will make all LEDs and the buzzer come on.

[Buzzer] ]On/Off/High/Low] e.g broadcast BuzzerOn

Variables
You can use variables instead e.g Set Led1 On will turn on 1st LED
And also use Power1..6 (values 0-100) variables to vary the brightness as

Sensor
There is only one sensor value returned and that is called switch (1 if not pressed – 0 if pressed)

PiRoCon

This board is a complete robotics controller for your Raspberry Pi based mobile robot.

3 thoughts on “Ultrasonic Sensor

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s