repo for instructions and code to produce a audio (wav) player from a simple sd card and an attiny(85) avr chip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

223 lines
6.8 KiB

_ _ _____ _______ ___
| | | |/ _ \ \ / /_ _/ _ \
| |_| | | | \ \ /\ / / | || | | |
| _ | |_| |\ V V / | || |_| |
|_| |_|\___/ \_/\_/ |_| \___/
FLASHING (PUTTING .HEX Files on your ATtiny)
-needed-
*Arduino Uno or Duemilanove (w/ an ATmega328, not an older board with an ATmega168)
*ATtiny45 or ATtiny85 (8-pin DIP package)
*a 10 uF capacitor
*a breadboard
*8x jumper wires
*Arduino IDE
-flashing the arduino to act as programmer-
*Open Arduino, add ATTiny support > http://highlowtech.org/?p=1695
*Load: File>Examples>11.ArduinoISP
*Connect arduino to computer and select the right board, and port from the Tools menu (aka arduino Uno)
*Upload the sketch to the arduino board
*Disconnect arduino
-wiring-
*wire up the arduino to the attiny, see schematic arduino-to-attiny-wiring.png or http://highlowtech.org/wp-content/uploads/2011/06/Screen-shot-2011-06-06-at-1.46.39-PM.png
Pin connections:
ATtiny Pin 2 to Arduino Pin 13 (or SCK of another programmer)
ATtiny Pin 1 to Arduino Pin 12 (or MISO of another programmer)
ATtiny Pin 0 to Arduino Pin 11 (or MOSI of another programmer)
ATtiny Reset Pin to Arduino Pin 10 (or RESET of another programmer)
(ATtiny pinout refer to schematic: https://cdn.sparkfun.com/assets/f/8/f/d/9/52713d5b757b7fc0658b4567.png )
NOTE REPEAT THE STEPS BELOW FOR EVERY ATTINY CHIP YOUR PLANNING TO USE/PROGRAM:x
*Connect arduino to computer again
*In arduino ide select:
Tools – Board – Attiny85 @ 8Mhz (internal oscillator; BOD disabled)
Tools – Programmer – Arduino as ISP
Tools – Serial Port – COMx (x being the com port that your arduino is connected to)
*Finally:
Tools – Burn Bootloader
To clarify, you are not burning a bootloader here. You are resetting the fuses in the Attiny to clock it at 8Mhz (normally runs at 1Mhz).
Next, get the firmware into the chip. With that I mean the hex file you want in your chip
-flashing the firmware with avrdude (bundled with arduino on OSX)-
*On osx, open a Terminal and type: cd /Applications/Arduino.app/Contents/Java/hardware/tools/avr/bin/
*Press enter ;)
*Youre now in the folder with all the avr stuff.
The commands ater the dollarsign below are all executed from this folder aka typed in the terminal followed by the ENTER key.
(so dont type the dollar sign)
$ ./avrdude (lists available commands)
-create makefile-
*to compile code (.c) to binary .hex using a 'makefile', create a new one or modify an exiting one (see led example)
*make sure all the paths are correct! (on osx avrdude etc is not in your 'path', or /usr/bin/, so you need full paths to these apps!)
(ref: http://www.instructables.com/id/Honey-I-Shrunk-the-Arduino-Moving-from-Arduino-t/
and: https://github.com/internaut/attiny-instructable)
type: $ make
Now you have a main.hex
-flashing hex-
$ cd /Applications/Arduino.app/Contents/Java/hardware/tools/avr
$ ./bin/avrdude -C etc/avrdude.conf -c avrisp -P /dev/cu.usbmodem1421 -b 19200 -p attiny85 -U flash:w:/Users/then/ownCloud/space/linuxpresday/attiny-instructable-master/1_leds/main.hex:i
BOOM!
To test, just need to connect pin 5 (PB0) and/or 6 (PB1) of your ATtiny with an LED respectively (of course you need to add a resistor with at least 150 Ohm before). (http://www.instructables.com/id/Honey-I-Shrunk-the-Arduino-Moving-from-Arduino-t/)
-flash SDCARD CODE-
$ ./bin/avrdude -C etc/avrdude.conf -c avrisp -P /dev/cu.usbmodem1421 -b 19200 -p attiny85 -U flash:w:/Users/then/ownCloud/space/linuxpresday/attinydj/install/tiny.hex:i
-put content on sd card-
place (48 kHz, 8-bit, mono) wav files in an FAT (32) formatted sd card folder called "wav".
(ref:http://www.instructables.com/id/Attiny85-Sd-Wav-Player/)
>> oef check this>> http://elm-chan.org/works/sd20p/report.html (put 001.wav file in root)
CONNECTING micro SD CARD TO ATTINY85
see: schemasd8p_mo.png
and: sdcard-pinout.png
-soldering to the SD CARD (not micro sd)
vss1 and vss2 are GND (can be connected together)
see: sdcard-pinout.png
Sprites mod has an excellent schematic: http://spritesmods.com/?art=doorbell&page=2
(schema.png)
ref:
http://www.sonsivri.to/forum/index.php?topic=7156.0
https://www.esp32.com/viewtopic.php?t=2272
http://spritesmods.com/?art=doorbell&page=2
FURTHER READING AND CREDITS:
http://elm-chan.org/works/sd8p/report.html -- original creator, great site!
http://www.instructables.com/id/Attiny85-Sd-Wav-Player/ -- tut for raspberry pi as programmer
---
attiny sd player... attiny soldered directly on cheap sdcard
diy programming shield:
https://www.youtube.com/watch?v=9LjfkjwMqXI
better> https://www.youtube.com/watch?v=BexXvxmOGN8
brogramming the chip
http://highlowtech.org/?p=1695
smart sdcard microsd adaptor hack:
https://www.youtube.com/watch?v=RVC_nLZy-T8
uiteindelijk:
http://www.instructables.com/id/Attiny85-Sd-Wav-Player/
http://elm-chan.org/works/sd8p/report.html (fuses not needed rite? see: https://www.youtube.com/watch?v=RVC_nLZy-T8 )
harde site http://elm-chan.org/
interesting audacity tut halfway:
https://www.youtube.com/watch?v=tUapZ_JdHLE
hard:
http://txyzinfo.blogspot.nl/2012/11/AVR-attiny2313-wav-music-player-from-SD-card-microSD-MMC.html
https://www.youtube.com/watch?v=CDRRwNkzasQ
more advanced, with pcb etcahble:
http://paja-trb.cz/konstrukce/wav_player.html
__ _____ ____ _ ______ _ _ ___ ____
\ \ / / _ \| _ \| |/ / ___|| | | |/ _ \| _ \
\ \ /\ / / | | | |_) | ' /\___ \| |_| | | | | |_) |
\ V V /| |_| | _ <| . \ ___) | _ | |_| | __/
\_/\_/ \___/|_| \_\_|\_\____/|_| |_|\___/|_|
musical keycord
PARTS NEEDED
(micro) SD CARDS (ebay) <1eur
https://www.ebay.nl/itm/Job-lot-of-44-Used-Micro-SD-Memory-Cards-All-2GB-Various/253593350905?hash=item3b0b5772f9:g:rsEAAOSwyi1a5s7G&autorefresh=true
per unit:
1x atttiny85 (farnell)
1x speaker (eculit?)
1x cr2032 (3v lithium cell)
1x (micro)sdcard
BATTERY
the circuit draws 0.03A the cr2032 lithium battery delivers about 200 mah, so battery life is 200/3 = 66 hours, almost 3 days of operation time.
SOUNDS
According to ELM CHang: “The SD audio player supports only RIFF-WAVE format sound files known as Microsoft wave file in LPCM, 8/16-bit, mono/stereo and upto 48kHz sampling rate”.
(http://elm-chan.org/works/sd8p/report.html)
But this is not the case…..
workflow: convert mp3 to wav, convert wav to speed it up 2x
$ ffmpeg -i input.mp3 output.wav
$ sox output.wav -r 48000 -c 1 -b 8 short2x48-8.wav speed 2
To convert a whole folder (zhell, osx, etc..):
$ for i in *.mp3; do ffmpeg -i "$i" ${i%.*}.wav; done
$ for i in *wav; do sox "$i" -r 48000 -c 1 -b 8 ${i%.*}-conv.wav speed 2; done
ref:
http://stefaanlippens.net/audio_conversion_cheat_sheet/
http://elm-chan.org/works/sd8p/report.html
COSTS
6x sdcards (marktplaats) 6,50+5,85 … = 12,35
6x attiny a 1,08 = 6,36
6x CR 2032 a 0,884 = 5,404
6x speaker…