Shop OBEX P1 Docs P2 Docs Learn Events
Kinda lost... — Parallax Forums

Kinda lost...

BaTWING_2000BaTWING_2000 Posts: 6
edited 2009-11-29 04:29 in Learn with BlocklyProp
On page 227 of the what is a microcontroller it is asking me to:

"Modify MixingTones.bs2 so that it cycles through the Freq2 arguments
ranging from 2001 to 2005 using a word variable and a loop.

I'm dont exactly get what I'm supposed to do here. Anyone please help thx..

This is MixingTones.bs2:
========================================

' {$STAMP BS2}
' {$PBASIC 2.5}
DEBUG "Frequency = 2000", CR
FREQOUT 9, 4000, 2000
DEBUG "Frequency = 3000", CR
FREQOUT 9, 4000, 3000
DEBUG "Frequency = 2000 + 3000", CR
FREQOUT 9, 4000, 2000, 3000
DEBUG "Frequency = 2000 + 2001", CR
FREQOUT 9, 4000, 2000, 2001
DEBUG "Frequency = 2000 + 2002", CR
FREQOUT 9, 4000, 2000, 2002
DEBUG "Frequency = 2000 + 2003", CR
FREQOUT 9, 4000, 2000, 2003
DEBUG "Frequency = 2000 + 2005", CR
FREQOUT 9, 4000, 2000, 2005

DEBUG "Frequency = 2000 + 2010", CR
FREQOUT 9, 4000, 2000, 2010
DEBUG "Done", CR
END

========================================

Post Edited (BaTWING_2000) : 11/29/2009 4:16:49 AM GMT

Comments

  • SRLMSRLM Posts: 5,045
    edited 2009-11-29 04:05
    It wants you to use a loop (either FOR or WHILE) to condense the code from about a dozen lines to about four. Look up how to use a loop to increment a variable.
  • BaTWING_2000BaTWING_2000 Posts: 6
    edited 2009-11-29 04:29
    yay. I think I got it [noparse]:)[/noparse]

    =================
    freq2 VAR word

    FOR freq2 = 2000 TO 2005 STEP 1
    DEBUG "Frequency = 2000 + ", DEC4 freq2, CR
    FREQOUT 9, 4000, 2000, freq2
    NEXT
    =================

    stupid me was focusing on the DO LOOP arguments and didn't think of the FOR NEXT
    (even tough it was just covered). Yah I'm a dee dee dee sometimes. Thanks SRLM
Sign In or Register to comment.