ErgoJr, Snap4Arduino and HC-SR04 UltraSound sensor

Thanks to the PoppyEducation team, I have (joint) custody of an ErgoJr for a few days. I decided to try to give him eyes (should I say ears ?) with the popular HC-SR04 ultrasound sensor for Arduino.
Using Snap4Arduino to command a Poppy robot is very easy (tutorial here), but it was a bit harder to use the sensor.
First of all, thanks to the Playmais of my daughter, I managed quite easily to fix the sensor in the head of the Ergo :

Make the sensor work in Snap4Arduino was a bit tricky.
A block and an UltraSoundFirmata can be found here, but the firmata doesn’t work with the HC-SR04 sensor.
As explained here, you have to modify a few lines of a function inside the firmata, before uploading it to your Arduino.

After that everything works like a charm in Snap4Arduino !

Little example (starring : my daughter and her Playmais) :
If ErgoJr detects a presence he’s curious and goes ahead, but he gets scared if the hand is too close.
And if the hand is really too close, he decides to get back in his shell, in Tetris mode.

5 Likes

Pour la connexion avec un capteur ultrason HC-SR04, on peut trouver une solution tout faite à l’URL suivante

J’avais déjà testé ce module qui marche très bien, mais très joli ta déco au maïs :joy:

Oui en fait c’est la même personne qui a posté les lignes de code à changer, j’avais vu qu’il avait mis à disposition un firmata tout fait mais je ne l’avais pas testé. Donc tant mieux si ça marche, c’est plus simple.

Just loving what you did!

1 Like