Let's Make Robots! | RobotShop

Ultrasonic HC-SR04 library for AtMega 8 (ie Dagu Mini Driver)

Does anyone know of a library that will work with a Dagu Mini Driver (Arduino NG AtMega 8) and an HC-SR04?  At first I thought I must have two sensors that are dead, but when I hook them up to an Arduino they work fine.

I tried our friend Google, but none of the ultrasonic libraries list if they are backwards compatible to the AtMega 8.  I tried two different libraries and neither seems to work.  I tried different pins, still no joy.

Thanks in advance,





Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

That code is almost exactly the same code I got from one of the libraries I tried.  That code didn't work and this code doesn't work either.  I get 0 for ranges no matter what I do.

I copy and pasted the code into my IDE, so not a code issue.  I then hooked up one of my Arduino Unos and the code worked.  I tried another Mini Driver, and still no joy.  I swapped inputs for trigger and echo, tested to make sure I had power at the sensor (4.9 volts Vcc is +, Gnd is - so kind of hard to mess up).  I was using the USB port for power which should be more than enough but hooked up an external power supply to make sure power wasn't an issue.  I am using Arduino 1.02 IDE and using the Visual Micro plug-in within Visual Studio 2010.  I used this setup earlier this week and had the bot working with the built in FET H bridge on the board  running around my kitchen.  The bot has bumper switches which worked so I am using the right row of pins for the inputs/outputs.   It seems it is only the ultrasonic code that it doesn't want to work on.

Could it be a jumper, bad version of software, or something silly like that?