Shop OBEX P1 Docs P2 Docs Learn Events
What's wrong with this code? — Parallax Forums

What's wrong with this code?

Velvet LeopardVelvet Leopard Posts: 47
edited 2004-08-18 05:01 in BASIC Stamp
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

Comments

  • AlWilliamsAWCAlWilliamsAWC Posts: 135
    edited 2004-08-17 21:05
    Your index variable is a nib which is 4 bits and can only hold up to 15. You need to change it to a byte.

    Regards,

    Al Williams
    AWC
    8 Channels of PWM
    http://www.awce.com/pak5.htm
    ·
  • Velvet LeopardVelvet Leopard Posts: 47
    edited 2004-08-17 21:08
    I knew I had to be overlooking smething.· Thanks alot.· Now is that manual downloadable from Parallax?
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-08-17 21:37
    Open the Help file and have a read through the section called "Memory and Variables."

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
  • jakjrjakjr Posts: 88
    edited 2004-08-18 05:01
    Yes the programmign manual is avaliable for download click to download

    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.
Sign In or Register to comment.