' Vmusic2 Demo System ' Written by Mike Carter SurplusGizmos.com, LLC ' See Documentation at http://www.surplusgizmos.com/usefullstuph/vmusic2.htm ' ' This code is written in Bascom-AVR basic compilier. ' The comilied code will work with the demo version of ' the Bascom compilier which is available for free ' ' This code is free to use and modify for any use under the folowing condition: ' this code is not guaranteed in any way... ' if you find a better way of doing things, find mistakes, or ??? let us know so we can pass it on... ' ' With that out of the way enjoy and keep tinkering away... ' ' Uses ATtiny2313 IC ' Pin D.0 is Recieve (not used in this code currently) ' Pin D.1 is Transmit (conected to Recieve on Vmusic2 unit) ' Pin B.0 thru B.4 are momentary switch inputs (when pulled low they are pushed) ' ' ' The mp3 file names I use were just easy ones I chose but you can use whatever you wish. ' I believe it supports Fat16 file names which are 8 charecters dot 3 charectors such as 12345678.mp3 ' I have not tested to see if it supports spaces in file names or longer than 8 charecters ' '$regfile = "m8def.dat" $regfile = "attiny2313.dat" $crystal = 8000000 $hwstack = 32 ' default use 32 for the hardware stack $swstack = 10 ' default use 10 for the SW stack $framesize = 40 Dim Cr As Byte 'This is the cariage return sent after each command Cr = &H0D Config Debounce = 30 'set the debounce time to 30ms for switches Config Portb = Input ' we are using Portb for switch inputs ' "vpf what.wav" ' "vpf nmnl.mp3" ' "vpf power.mp3" ' Print "vpf nmnl.mp3" ; Chr(cr); Config Com1 = 9600 , Synchrone = 0 , Parity = None , Stopbits = 1 , Databits = 8 , Clockpol = 0 Wait 5 Dastart: 'all code has to start somewhere Debounce Pinb.0 , 0 , Bt1 'pinb.0 is pin, trigers on a low or zero volt, jumps to Bt1 when triggered Debounce Pinb.1 , 0 , Bt2 'pinb.1 Debounce Pinb.2 , 0 , Bt3 Debounce Pinb.3 , 0 , Bt4 Debounce Pinb.4 , 0 , Bt5 ' ^----- label to branch to ' ^---------- Branch when P1.0 goes low(0) ' ^---------------- Examine this pin Pinb.1 'example When Pinb.0 goes low jump to subroutine Pr Goto Dastart ' go back to the start to check the buttons again End Bt1: Print "vpf 1.mp3" ; Chr(cr); 'send "vpf 1.mp3" to the Vmusic2 ' ^--------- CHR(cr) sends a cariage return ' ^--- the semicolon ; says do not send a linefeed ' (Vmusic gives error if a LF is sent. that took me awhile to figure out.) :( ' ^---- the command to be sent in quotes Wait 2 Goto Dastart Bt2: Print "vpf 2.mp3" ; Chr(cr); 'send "vpf 2.mp3" to the Vmusic2 Wait 2 Goto Dastart Bt3: Print "vpf 3.mp3" ; Chr(cr); 'send "vpf 3.mp3" to the Vmusic2 Wait 2 Goto Dastart Bt4: Print "vpf 4.mp3" ; Chr(cr); 'send "vpf 4.mp3" to the Vmusic2 Wait 2 Goto Dastart Bt5: Print "vpf nmnl.mp3" ; Chr(cr); 'send "vpf nmnl.mp3" to the Vmusic2 ' nmnl.mp3 is 'no more no less' by Mercy Me a very rockin song Wait 2 Goto Dastart End