Shop OBEX P1 Docs P2 Docs Learn Events
BS2 — Parallax Forums

BS2

Henry KuaHenry Kua Posts: 2
edited 2004-08-31 15:08 in BASIC Stamp
Hi there,
I am henry, i have a problem with my programming. I am now doing a project which interface to the NOKIA 30 Modem which can sent sms using switches.
Eg
Switch 1 is depressed message "Hazel how are u???" will be send out.
Switch 2 is depressed message "Programming is fun..." will be sent out.

but this will work when individual switches are drepressed and individual message will be sent out so when i press switch 1 it will·sent out message 1 only after message 1 sent out then i press switch 2 message 2 will sent out. but when i press switch 1 & 2 at the same time it cannot sent the two message so i wonder is it my programming problem or i need to put the message in que so that it will put the message in que and sent out individually if it sense which switch is depressed 1st. if both switch is depressed it must sent out 2 message so how to do it.

Thanks
Henry

The Program are as follow:

' {$STAMP BS2}
' {$PBASIC 2.5}
' {$PORT COM1}
task··········· VAR···· Nib
CHOICE··· VAR·· Byte
Main:
IF IN3 = 1 THEN
DO
ON task GOSUB Task_0
PAUSE 100
LOOP
END
Task_0:
DEBUG "Running Task 0",CR
PAUSE 7000
SEROUT· 2,84,10,[noparse][[/noparse]"at",CR]
PAUSE 2000
SEROUT· 2,84,10,[noparse][[/noparse]"AT+CMGF=1",CR]
PAUSE 2000
SEROUT· 2,84,10,[noparse][[/noparse]"at+csca=",$22,"+6598540020",$22,$2C,"145",CR]
PAUSE 7000
SEROUT· 2,84,10,[noparse][[/noparse]"at+cmgs=",$22,"+6591234567",$22,$2C,"145",CR," Hazel how are u??? ",$1A]
PAUSE 5000
'serout 2,84,10,[noparse]/noparse
'pause· 2000
ENDIF

IF IN4 = 1 THEN
DO
ON task GOSUB Task_1
PAUSE 100
LOOP
END
Task_1:
DEBUG "Running Task 1",CR
HIGH 11
PAUSE 7000
SEROUT· 2,84,10,[noparse][[/noparse]"at",CR]
PAUSE 2000
SEROUT· 2,84,10,[noparse][[/noparse]"AT+CMGF=1",CR]
PAUSE 2000
SEROUT· 2,84,10,[noparse][[/noparse]"at+csca=",$22,"+6598540020",$22,$2C,"145",CR]
PAUSE 7000
SEROUT· 2,84,10,[noparse][[/noparse]"at+cmgs=",$22,"+6591234567",$22,$2C,"145",CR,"·Programming is fun...·",$1A]
PAUSE 5000
'serout 2,84,10,[noparse]/noparse
'pause· 2000
ENDIF
GOTO main

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2004-08-31 15:08
    You need to scan the switches at the same time, saving the inputs. When your button 1 code runs it takes a long time and you've released button 2. Try this:

    buttons VAR Nib

    Scan:
    · buttons.BIT0 = IN3
    · buttons.BIT1 = IN4


    Main:
    · IF (buttons.BIT0) THEN ....

    .
    .
    .


    · IF (buttons.BIT1) THEN ....


    .
    .
    .

    · GOTO Scan

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas Office
Sign In or Register to comment.