What's wrong with this code?
Velvet Leopard
Posts: 47
Hewwo, all.· I wrote this code to make a little song to cheer up my little bro.· I followed the steps in my "What's a Microcontroller" kit, but no go.· After the 16th cycle of the (for next) loop, it repeats from the beginning and it never stops despite the (end) command.· My kit did not come with a Basic Stamp II User's Manual.· Where can I get the manual?
'{$STAMP BS2}
'{$PBASIC 2.5}
Notes DATA "C","C","G","G","A","A","G","F","F","E","E","D","D","C",
·········· "G","G","F","F","E","E","D","G","G","F","F","E","E","D"
Frequencies DATA Word 2093, Word 2093, Word 3136, Word 3136,
················ Word 3520, Word 3520, Word 3136, Word 2793,
················ Word 2793, Word 2637, Word 2637, Word 2349,
················ Word 2349, Word 2093, Word 3136, Word 3136,
················ Word 2793, Word 2793, Word 2637, Word 2637,
················ Word 2349, Word 3136, Word 3136, Word 2793,
················ Word 2793, Word 2637, Word 2637, Word 2349
Durations DATA Word 500, Word 500, Word 500, Word 500,
·············· Word 500, Word 500, Word 1000, Word 500,
·············· Word 500, Word 500, Word 500, Word 500,
·············· Word 500, Word 1000, Word 500, Word 500,
·············· Word 500, Word 500, Word 500, Word 500,
·············· Word 500, Word 500, Word 500, Word 500,
·············· Word 500, Word 500, Word 500, Word 500
index VAR Nib
noteLetter VAR Byte
noteFreq VAR Word
noteDuration VAR Word
DEBUG "Note· Duration· Frequency", CR,
····· "____· ________· _________", CR
FOR index = 0 TO 27
· READ Notes + index, noteLetter
· DEBUG "·· ", noteLetter
· READ Durations + (index * 2), Word noteDuration
· DEBUG "····· ", DEC4 noteDuration
· READ Frequencies + (index * 2), Word noteFreq
· DEBUG "······ ", DEC4 noteFreq, CR
· FREQOUT 9, noteDuration, noteFreq
NEXT
END
'{$STAMP BS2}
'{$PBASIC 2.5}
Notes DATA "C","C","G","G","A","A","G","F","F","E","E","D","D","C",
·········· "G","G","F","F","E","E","D","G","G","F","F","E","E","D"
Frequencies DATA Word 2093, Word 2093, Word 3136, Word 3136,
················ Word 3520, Word 3520, Word 3136, Word 2793,
················ Word 2793, Word 2637, Word 2637, Word 2349,
················ Word 2349, Word 2093, Word 3136, Word 3136,
················ Word 2793, Word 2793, Word 2637, Word 2637,
················ Word 2349, Word 3136, Word 3136, Word 2793,
················ Word 2793, Word 2637, Word 2637, Word 2349
Durations DATA Word 500, Word 500, Word 500, Word 500,
·············· Word 500, Word 500, Word 1000, Word 500,
·············· Word 500, Word 500, Word 500, Word 500,
·············· Word 500, Word 1000, Word 500, Word 500,
·············· Word 500, Word 500, Word 500, Word 500,
·············· Word 500, Word 500, Word 500, Word 500,
·············· Word 500, Word 500, Word 500, Word 500
index VAR Nib
noteLetter VAR Byte
noteFreq VAR Word
noteDuration VAR Word
DEBUG "Note· Duration· Frequency", CR,
····· "____· ________· _________", CR
FOR index = 0 TO 27
· READ Notes + index, noteLetter
· DEBUG "·· ", noteLetter
· READ Durations + (index * 2), Word noteDuration
· DEBUG "····· ", DEC4 noteDuration
· READ Frequencies + (index * 2), Word noteFreq
· DEBUG "······ ", DEC4 noteFreq, CR
· FREQOUT 9, noteDuration, noteFreq
NEXT
END
Comments
Regards,
Al Williams
AWC
8 Channels of PWM
http://www.awce.com/pak5.htm
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon Williams
Applications Engineer, Parallax
Dallas Office
Like an idiot I downloaded and printed the WHOLE manual then the next day I bought a boe-bot kit which contained that manual, what a waste of ~200 sheets of paper and nearly half of a $30+ ink catridge.