Power supply

Glad to hear you solved the problem.

And don’t feel bad, I know I’ve ruined a bunch of components with my poor breadboard etiquette (including some microcontrollers, h-bridges, and even a nice little sonar sensor!). When I can make myself do it, I find it’s usually worth the time to trim down the component leads so they sit snug to the board. Another tip it took me a while to start following is never make changes to a powered breadboard. Even if you don’t brush contacts against each other, the intermediate partially assembled/disassembled circuit can behave in unexpected and unusual ways. I almost ruined a $55 pressure transducer on a breadboard because I decided to replace a voltage regulator with another that had a different pin order. I started by removing the ground wire from the first voltage regulator, but without a ground connection, a voltage regulator basically becomes a wire from the input pin to the output pin, passing through your source voltage! Fortunately I noticed an LED on the board get much brighter and pulled the power!

If you really want to make your Orangutan’s timing more accurate you can connect an external crystal oscillator to your AVR (the Orangutan’s even have a place to solder one on the back of the board). In addition to the crystal, you will need two capacitors, specified in the oscillator’s datasheet. To run the microcontroller off of an external clock you will need to change the clock fuses, the ones everyone says never to change, but that’s just because if you make the switch without an external clock connected you’ll need to connect one to be able to switch it back.

You’re probably fine with just the internal RC oscillator, and there are also some tricks described in the ATMega8 datasheet to calibrate the oscillator to within 1%. I generally don’t even bother with that. For a lot of applications you want faster processing speed, but you don’t necessarily need increased accuracy, and you can use a ceramic resonator instead (the Baby Orangutans come with 20MHz ceramic resonators). They’re not as accurate as crystal oscillators, but they’re cheaper, and you can get them with the capacitors built in, so you don’t have to mess with as many components.

-Adam

OK so even if i change to using interrupts instead, the error is still there, and the oscillator i have is from the spark fun tutorials about using an external oscialltor, so at a later stage, after finishing my ittle program with interupts, i could add it in for increased accuracy!