Exciting New Project (A least for me =) )
jdpetersdoc
Posts: 26
' {$STAMP BS2} ' {$PBASIC 2.5}
Spkr PIN 10 ' output pin for FREQOUT TmAdj CON $100 ' x 1.0 (time adjust) FrAdj CON $100 ' x 1.0 (freq adjust)
Main: DO
IF IN1 = 1 THEN HIGH 11 PAUSE 1000 LOW 11 PAUSE 500 DEBUG CLS, "Let's call home :-)" ' combine 350 Hz & 440 Hz FREQOUT Spkr, 5000 */ TmAdj, 350 */ FrAdj, 440 */ FrAdj ' dial number (digits 150 ms on, 25 ms off) DTMFOUT Spkr, 150 */ TmAdj, 200, [noparse][[/noparse]6, 9, 5, 4, 7, 6, 8] PAUSE 3000 FREQOUT Spkr, 2000 */ TmAdj, 440 */ FrAdj, 480 */ FrAdj PAUSE 4000 FREQOUT Spkr, 2000 */ TmAdj, 440 */ FrAdj, 480 */ FrAdj PAUSE 4000 FREQOUT Spkr, 2000 */ TmAdj, 440 */ FrAdj, 480 */ FrAdj PAUSE 4000 FREQOUT Spkr, 2000 */ TmAdj, 440 */ FrAdj, 480 */ FrAdj PAUSE 4000 FREQOUT Spkr, 2000 */ TmAdj, 440 */ FrAdj, 480 */ FrAdj PAUSE 4000 FREQOUT Spkr, 2000 */ TmAdj, 440 */ FrAdj, 480 */ FrAdj
IF IN2 = 1 THEN HIGH 12 PAUSE 1000 LOW 12 PAUSE 500 DEBUG CLS, "Lets call Joshua's cellphone :-)" ' combine 350 Hz & 440 Hz FREQOUT Spkr, 5000 */ TmAdj, 350 */ FrAdj, 440 */ FrAdj ' dial number (digits 150 ms on, 25 ms off) DTMFOUT Spkr, 150 */ TmAdj, 200, [noparse][[/noparse]1, 9, 8, 9, 5, 1, 3, 2, 3, 4, 5] PAUSE 3000 FREQOUT Spkr, 2000 */ TmAdj, 440 */ FrAdj, 480 */ FrAdj PAUSE 4000 FREQOUT Spkr, 2000 */ TmAdj, 440 */ FrAdj, 480 */ FrAdj PAUSE 4000 FREQOUT Spkr, 2000 */ TmAdj, 440 */ FrAdj, 480 */ FrAdj PAUSE 4000 FREQOUT Spkr, 2000 */ TmAdj, 440 */ FrAdj, 480 */ FrAdj PAUSE 4000 FREQOUT Spkr, 2000 */ TmAdj, 440 */ FrAdj, 480 */ FrAdj PAUSE 4000 FREQOUT Spkr, 2000 */ TmAdj, 440 */ FrAdj, 480 */ FrAdj
IF IN3 = 1 THEN HIGH 13 PAUSE 1000 LOW 13 PAUSE 500 DEBUG CLS, "Lets call Dad's cellphone :-)" ' combine 350 Hz & 440 Hz FREQOUT Spkr, 5000 */ TmAdj, 350 */ FrAdj, 440 */ FrAdj ' dial number (digits 150 ms on, 25 ms off) DTMFOUT Spkr, 150 */ TmAdj, 200, [noparse][[/noparse]1, 9, 8, 9, 4, 3, 0, 0, 9, 3, 6] PAUSE 3000 FREQOUT Spkr, 2000 */ TmAdj, 440 */ FrAdj, 480 */ FrAdj PAUSE 4000 FREQOUT Spkr, 2000 */ TmAdj, 440 */ FrAdj, 480 */ FrAdj PAUSE 4000 FREQOUT Spkr, 2000 */ TmAdj, 440 */ FrAdj, 480 */ FrAdj PAUSE 4000 FREQOUT Spkr, 2000 */ TmAdj, 440 */ FrAdj, 480 */ FrAdj PAUSE 4000 FREQOUT Spkr, 2000 */ TmAdj, 440 */ FrAdj, 480 */ FrAdj PAUSE 4000 FREQOUT Spkr, 2000 */ TmAdj, 440 */ FrAdj, 480 */ FrAdj
ENDIF
LOOP
·Ok first things first i'm starting a a new project thats basicaly a telephone (Yes your herd me right ) I have three push button switchs that connect to the to a basic STAMP 2. There are three LEDS also. I need a little help on my programing. Heres what the program is supose to do: WHen ever I press one of the three buttons the programed DTMF tones will sound off basicaly a phone number. I have the main program setup but my IF and THEN ENDIF commands arent quite correct =(.
·If I could have some help it would be a great help.
P.S I'm going to connect this setup to my telephone line so it can call any phone numbe I want =P.
Comments
DO
'Check buttons here.
IF IN?=1 (or zero) THEN GOSUB PH1
'May need an ENDIF after each IF, not sure.
IF IN?=1 THEN GOSUB PH2
IF IN?=1 THEN GOSUB PH3
ENDIF
LOOP
PH1:
Enter your first phone number dialing routine here.
RETURN
PH2:
Enter your secound phone number routine here.
RETURN
PH3:
Lather, rinse and repeat.
RETURN
Double-check my syntax and use of GOSUB/RETURN,·as I'm not near my Stamp stuff right now.· You may also need an ENDIF after each IF, but I'm not sure without checking the manual.· Replace IN? with the pin for your buttons.· As you gain confidence/experience, you may want to try using·DATA statements to hold the phone numbers, with LOOKUP·to·retrieve them, this may·reduce your code size.
Be VERY careful when trying to interface to the phone lines.· I'd suggest using the piezo or a speaker to produce the tones and place the handset near the speaker, kind of like the really old school·modems.· DO NOT try and connect the Stamp directly to·the·phone lines!· The·Stamp won't like the voltages present there and will be·damaged.
Post Edited (Desy2820) : 11/5/2008 2:41:55 AM GMT
The cautions about connecting to the phone line are correct. When off-hook, there's only about 7-12 volts DC or so, but it may be in either direction. On-hook and not ringing, expect at least 50 volts DC, and sometimes as much as 80 -- also unpredictably in either direction. On-hook and ringing, there will be about 70 vrms of AC (typically 20 Hz) superimposed on the 50-80 volts DC. This is enough to fry the Stamp, fry you too, and make a pot of coffee for the mourners.
There are suggestions in the Stamp manual (also under the DTMFOUT command) on how to hook up to phone lines safely.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
· -- Carl, nn5i
+1 to what Carl is saying -- be very careful. This is why people use modems for this sort of thing.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Engineering