I am trying to use the HC-SR04 Ultrasonic sensor to measure distance through a very basic program of just sending the trig pulse and receiving the echo pulse. The circuit and the code work perfectly fine with the Redboard, however when I move it over to the Redboard Artemis the code does not work. Rather than printing the distance, it just prints 0 inches over and over. Does anyone have any ideas of why this sensor would not work with the Artemis or how to fix it? As I said, using the exact same code and wiring works on the Redboard.
Thanks for reaching out to us on this.
We have not yet released code for this set-up on the Artemis. The Artemis is radically different than Arduino. Some code is written specifically to use some parts inside an ATmega328 that you find on an Uno and those devices don’t exist on the Artemis or work differently. That can cause the code to either not compile or malfunction.
It might be best to rewrite the code a few different ways to see what works for that set-up, or hopefully someone who has an working example will stop by and share their code.
Best of luck!