Can a 4-pin HC-SR04 ultrasonic sensor be used on the parallax board, i.e. with PropellerC?
in Robotics
Can a 4-pin HC-SR04 ultrasonic sensor be used on the parallax board, i.e. with PropellerC?
I assume so.
Is there a tutorial or description.
I have an activitybot and have it working with the Parallax 3-pin sensor.
I had purchased two more sensors for use with an Arduino board I was going to try with some projects I have in mind.
I am working with my son on a maze solving robot and would like to connect three sensors.
Thanks for any help
dakotaknut
I assume so.
Is there a tutorial or description.
I have an activitybot and have it working with the Parallax 3-pin sensor.
I had purchased two more sensors for use with an Arduino board I was going to try with some projects I have in mind.
I am working with my son on a maze solving robot and would like to connect three sensors.
Thanks for any help
dakotaknut

Comments
Welcome to the forums! Yes, you can use those sensors with an Activity board. The PING is a much higher quality unit, but we've all been tempted by those $1 HC-SR04s. Like the PING shown at http://learn.parallax.com/activitybot/build-and-test-ping-sensor-circuit, you'll power it with 5V and use two resistors to interface to the 3.3V Propeller.
The four pin HC-SR04 has seperate TRIGger and ECHO pins, requiring two Prop I/O pins. BUT... there is a top secret, insider-exclusive, eyes-only, password-protected, secret-handshake-required, simple one-resistor modification to make it function on just one I/O pin. See this long-winded thread with lots of juicy info: http://forums.parallax.com/discussion/comment/1301893/#Comment_1301893
https://gist.github.com/flakas/3294829#file-hc-sr04-ino-L82
There are some build problems
Serial.begin doesn't work, but I don't think I need it
OUTPUT, LOW, and HIGH are all problems.
The example didn't show the header file I would need.
I am looking for examples of the use of these.
For example pinMode([pin], OUTOUT);
and digitalwrite([pin], LOW);
LOW and HIGH are undoubtedly as simple as 0 and 1.
I recollect seeing OUTPUT in an example sometime back when I was working on this a little bit.
I would like to use a header file for these. I assume that would be the best.
Thank you
I can't wait to take a look at this.
#include "simpletools.h" /* HC-SR04 Sensor https://www.dealextreme.com/p/hc-sr04-ultrasonic-sensor-distance-measuring-module-133696 This sketch reads a HC-SR04 ultrasonic rangefinder and returns the distance to the closest object in range. To do this, it sends a pulse to the sensor to initiate a reading, then listens for a pulse to return. The length of the returning pulse is proportional to the distance of the object from the sensor. The circuit: * VCC connection of the sensor attached to +5V * GND connection of the sensor attached to ground * TRIG connection of the sensor attached to digital pin 14 * ECHO connection of the sensor attached to digital pin 15 Original code for Ping))) example was created by David A. Mellis Adapted for HC-SR04 by Tautvidas Sipavicius This example code is in the public domain. */ const int trigPin = 14; const int echoPin = 15; int main() { while(1) { // The sensor is triggered by a HIGH pulse of 10 or more microseconds. // Give a short LOW pulse beforehand to ensure a clean HIGH pulse: low(trigPin); pulse_out(trigPin, 10); // Read the signal from the sensor: a HIGH pulse whose // duration is the time (in microseconds) from the sending // of the ping to the reception of its echo off of an object. long tEcho = pulse_in(echoPin, 1); // convert the time into a distance int inDist = tEcho / 148; int cmDist = tEcho / 58; print("%d inch\n", inDist); print("%d cm\n", cmDist); pause(200); } }