Digistump Cricket Generator

A little toy for Digistump fans – a cricket generator.

What is a Digistump? It’s just a little Arduino – i.e. An Atmel-based board. Any similar board will do – maybe changing the pins – a UNO for example…  the Digistump uses the little 8 pin ’85 chip. On a larger board such as a UNO you could use D13 and D12 outputs for example – the pins are defined at the top of the software.

Recently for a bit of fun we sat down and made a cricket generator.  A couple of things are important – this needs to sound like an insect and not as most do, sound like an electronic buzzer. We did find one excellent generator on YouTube – but I think it was a con as the guy’s code simply bore no resemblance to the output – so we made our own.

The second thing that is important is power as presumably one would like this to run off solar or maybe charge off solar.The Narcoleptic library lets you have delays in which the processor is off – down to a few micro-amps. So we used that – BUT the settings in the library would not allow the use of the Digistump – threw up an error – so in the Narcoleptic.cpp file – simply change WDTSCR to WDTCR – 3 occurrences  OR make the change in a more sophisticated way as here  http://forum.arduino.cc/index.php?topic=108870.0

Here’s the library: https://code.google.com/p/narcoleptic/

The Narcoleptic stuff above is ONLY to save power… you could just use DELAY if you wanted and forget the library.

So in this case – you need a piezo element (not a speaker – can’t handle the high frequency) across outputs P0 and P1 and I suggest once you’re happy  – snipping off the two surface mount LEDS as they use juice!

The cricket generator has variations as you’ll see in the first lot of code below – feel free to experiment – this will work on an Arduino without the mods mentioned above…. on other digital outputs of course… but the nice thing about the Digistump is that it’s cheap. Another way is just to program the ATTINY85 on it’s own – internal Xtal and fasten straight to a solar cell/battery arrangement capable of 3-5v output – an extension might be – read the voltage when set to internal reference by a VERY high value pair of resistors, measure the voltage of the solar cell (occasionally while sleeping the rest of the time) – if the cell is dead (ie nighttime) start chirping!.

cricket

The above was our first attempt….. then out of interest, I actually sat down and listened to a real recorded sample from one of the insects… firstly the main frequencies are around 5Khz, so that’s 200us. Usually around 125 of those followed by a 25ms break.. in groups of 5….  then there are maybe 3-4 of those bursts with something like 200ms between them- then a gap – anything from 2 seconds upwards.

I noted also that in each single burst of the high frequency, the level increases then drops off achieving soft edges to the waveform– I achieved that with PWM.  The actual frequency over each burst also increases slightly – I used the loop variable to add a decrementing delay while forming each sound block.

The gaps being a real creature are not AT ALL consistent – hence the random numbering to emulate what the real thing might do..

The result – will depend on the piezo you use but on mine – compared to a live recording – it’s not bad – not bad AT ALL… here’s the code – feel free to experiment. Half a dozen of these in the garden…..

If you REALLY want to go to town  – a movement sensor to make the thing shut up for a while when it senses movement nearby?

latest cricket

For articles on home control, some views and much more – take a look at my main blog.