A slightly more involved project than my usual uploads - but if anyone is feeling brave would like to experiment here goes...
I wanted to 'rig' an object to play a sound if it was moved. First obstacle - can an Arduino play a sound without additional hardware (and a DFPlayer setup probably would be little bulkier but a lot easier - but not as much fun? ) - yes it can...
So using a single transistor (as an amplifier) and a small 8ohm loudspeaker - I connected the speaker (via the transistor) to Pin11 on a Nano (this code is very Arduino (Uno, Nano or Mega) specific) - and a 256kbit i2c eeprom (24lc256) to pins a4 and a5 (my original plan was to use an SD card - but I couldn't find an SD card small enough to work) - so we are limited to 4s (32k) of 8bit sound. (As an aside - it would be possible to use 8 x 256kbit eeproms for 32s sound - and create a 'mini' digital recorder)
I modified my sender (from a while ago - note the filename to send is in properties) to strip the 44 byte wav header and using a i2c_eeprom component from some time ago - programmed the eeprom with 32k of sound (found online - although audacity can also export in this format (8 bit 8000 samples per second - mono here)
The 'player' program uses a double buffer - one buffer playing and one being read from i2c - and seems stable.. Sound is not 'hi-fi' but surprisingly good (much better than a musical birthday card !)
If anyone would like to try with an SD card - the output pin can be changed to pin 9 with a little code 'surgery'
The sample length is currently hardcoded - it would be an easy 'fix' to pop the size into locations 0 and 1 of the eeprom.
The sound is output using PCM...
1 post • Page 1 of 1