FREQOUT question
dragoneye
Posts: 2
Hello ,
I'd appreciate help on syntax.
I'm trying to write a program to allow for different frequencies to be output from a pin depending on which input pin is "energized"
This is what I wrote;
' {$STAMP BS2}
' {$PBASIC 2.5}
DO
DEBUG HOME
DEBUG ? IN1
DEBUG ? IN2
DEBUG ? IN3
DEBUG ? IN4
DEBUG ? IN5
DEBUG ? IN6
DEBUG ? IN7
IF (IN1=1) THEN
FREQOUT 8,1000,1
ELSEIF (IN2=1)THEN
FREQOUT 8,1000,2
ELSEIF (IN3=1)THEN
FREQOUT 8,1000,4
ELSEIF(IN4=1)THEN
FREQOUT 8,1000,9
ELSEIF(IN5=1)THEN
FREQOUT 8,1000,18
ELSEIF(IN6=1)THEN
FREQOUT 8,1000,36
ELSEIF(IN7=1)THEN
FREQOUT 8,1000,73
ELSEIF(IN8=1)THEN
FREQOUT 8,1000,146
ENDIF
LOOP
DEBUG "Tone done."
It seems to "get stuck" at one frequency regardless of which I/O pin is at "1". Also there is an annoying "gap" each time it cycles.
My goal is to have a mulitple position switch that determines which I/O pin is powered at any given time and to have an LED light flashing at the frequency determined by the so chosen pin continuously until power is switched to another or turned off.
Thanks for any help.
Rich
I'd appreciate help on syntax.
I'm trying to write a program to allow for different frequencies to be output from a pin depending on which input pin is "energized"
This is what I wrote;
' {$STAMP BS2}
' {$PBASIC 2.5}
DO
DEBUG HOME
DEBUG ? IN1
DEBUG ? IN2
DEBUG ? IN3
DEBUG ? IN4
DEBUG ? IN5
DEBUG ? IN6
DEBUG ? IN7
IF (IN1=1) THEN
FREQOUT 8,1000,1
ELSEIF (IN2=1)THEN
FREQOUT 8,1000,2
ELSEIF (IN3=1)THEN
FREQOUT 8,1000,4
ELSEIF(IN4=1)THEN
FREQOUT 8,1000,9
ELSEIF(IN5=1)THEN
FREQOUT 8,1000,18
ELSEIF(IN6=1)THEN
FREQOUT 8,1000,36
ELSEIF(IN7=1)THEN
FREQOUT 8,1000,73
ELSEIF(IN8=1)THEN
FREQOUT 8,1000,146
ENDIF
LOOP
DEBUG "Tone done."
It seems to "get stuck" at one frequency regardless of which I/O pin is at "1". Also there is an annoying "gap" each time it cycles.
My goal is to have a mulitple position switch that determines which I/O pin is powered at any given time and to have an LED light flashing at the frequency determined by the so chosen pin continuously until power is switched to another or turned off.
Thanks for any help.
Rich
Comments
after that , add the freqout part !
just a sugestion
Amaral
As to the gap, that's just something you'll have to live with. Each statement in PBASIC comes with some overhead, which will cause silent intervals between the FREQOUTs.
-Phil