Hurray! I've managed to add support of very popular HC-SR04 sensor. Here is what i've done. S4A changes...
And now the easy part – S4A firmware modification. - Add Ultrasonic lib (sources are attached)
- Remove 2, 3 pins configuration in “configurePins()” pinMode(2,INPUT); pinMode(3,INPUT); - Init ultrasonic var somowhere #include "Ultrasonic.h" Ultrasonic ultrasonic(3,2);
//(Trig, Echo)
- Use ultrasonic object in “sendSensorValues()” func instead of digital reading ScratchBoardSensorReport(6, digitalRead(2)?1023:0); ScratchBoardSensorReport(7, digitalRead(3)?1023:0); int distance = ultrasonic.Ranging(CM); ScratchBoardSensorReport(6, distance < 1024 ? distance : 0);
Here we are!
NOTE FOR DEVELOPERS: As you can notice, ultrasonic uses “pulseIn(Echo_pin,HIGH,3000);” function which limits timeout for echo receiving. Without specifying such limit arduino w/o properly attached HC-SR04 won't answer timely to S4A. That constant may be changed, or S4A step timing may be changed. For my purposes chosen constants (50 cm obstacle detection distance, 3 milliseconds) suit well, so i didn't conduct other experiments.
Hurray! I've managed to add support of very popular ... -
Hurray! I've managed to add support of very popular HC-SR04 sensor. Here is what i've done. S4A changes... Page 2. And now the easy part â S4A firmware ...