In this post I will detail how I used an ATtiny85 as a controller for an HC-SR04 sonar module (Ping sensor). The controller reads the inputs from up to 3 HC-SR04 modules and transmits the readings to an Arduino Mega via serial communication. This allows the Arduino Mega to pick up the readings whenever it is convenient rather than having to worry about complex timings. Let’s get started
First things first, we need to run the NewPing library on an ATtiny85/45/25. Until version 1.6 is released you will need to modify the library to do this. However, this removes some of the functions you might want to use on other boards. For this reason, I created the TinyNewPing Library. In it, I removed the parts that cause the errors on an ATtiny and gave it a new name so you can distinguish between the two. All the function names remain the same. If you still need more details check out THIS prior post.
Make a robot friend with Adafruit’s CRICKIT – A Creative Robotics & Interactive Construction Kit. It’s an add-on to our popular Circuit Playground Express, FEATHER and other platforms to make and program robots with CircuitPython, MakeCode, and Arduino. Start controlling motors, servos, solenoids. You also get signal pins, capacitive touch sensors, a NeoPixel driver and amplified speaker output. It complements & extends your boards so you can still use all the goodies on the microcontroller, now you have a robotics playground as well.