Shop OBEX P1 Docs P2 Docs Learn Events
Thread, 04-14-2011. Inputs to basic stamp. Att, Mike green. — Parallax Forums

Thread, 04-14-2011. Inputs to basic stamp. Att, Mike green.

Chez 7Chez 7 Posts: 4
edited 2011-04-16 18:34 in BASIC Stamp
Hi, am having problems sorting out Serin, Baudmode, Serial input, etc. Am 70 years of age and grey matter not working to well (no excuse) However, let me clarify a couple of pointers. My LEDs programme has no loops or GOTOs simply a staight sequence ie, High 1, Pause 1000, Low 1, Pause 45, High 2 , Pause 1000, Low 2 , Pause 45, etc, etc. Could I not use a "Wait " instead of the Pause 1000, and then use an input from the computer keypad to continue the programme ? I am talking about 200-500 milisecs "Wait" period, but it would vary each time I run the programme. Seems a straight forward procedure to me, but obviously a lot more complicated than I realise. Your help would be much appreciated. Chez 7.

Comments

  • Mike GMike G Posts: 2,702
    edited 2011-04-15 19:05
    There are no PBASIC WAIT commands. You could do a loop... SERIN has a timeout...Or SERIN can wait until a certain sequence is detected.

    How about posting your code? We can take a look and go from there.
  • Chez 7Chez 7 Posts: 4
    edited 2011-04-16 16:24
    Thanks for reply, the code is straight forward as below ;
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}

    G:
    PAUSE 1500
    HIGH 1
    PAUSE 1000
    LOW 1
    PAUSE 45

    HIGH 1
    PAUSE 1000
    LOW 1
    PAUSE 45
    HIGH 2
    PAUSE 1000
    LOW 2
    PAUSE 45
    HIGH 2
    PAUSE 1000
    LOW 2
    PAUSE 45
    etc
    etc
    I would like to be able to replace PAUSE 1000 with me being able to "control" the lenght of PAUSE eah time I run the programme, as you say Pbasic does not have a "wait" command.Is there an alternative? Thanks, Chez 7.
  • ercoerco Posts: 20,256
    edited 2011-04-16 18:28
    Instead of a PAUSE 1000, use a nice long loop (DO...LOOP or FOR...NEXT) which looks at button presses or other conditionals to exit the loop sooner. You can tune the length of the loop for the duration you need.
  • Mike GMike G Posts: 2,702
    edited 2011-04-16 18:34
    Take a look at this... A little verbose but straight forward.
    ' {$STAMP BS2p}
    ' {$PBASIC 2.5}
    delay1     VAR     Word
    delay2     VAR     Word
    delay3     VAR     Word
    value      VAR     Word
    
    
    Init:
      value = 1500
      GOSUB SetDelay1
      value = 1000
      GOSUB SetDelay2
      value = 45
      GOSUB SetDelay3
    
    Main:
    
    
      DEBUG CLS, "Enter Delay1: "
      GOSUB GetDelay
      GOSUB SetDelay1
    
      DEBUG CR, "Enter Delay2: "
      GOSUB GetDelay
      GOSUB SetDelay2
    
      DEBUG CR, "Enter Delay3: "
      GOSUB GetDelay
      GOSUB SetDelay3
    
      GOSUB Print
    
      PAUSE delay1
      HIGH 1
      PAUSE delay2
      LOW 1
      PAUSE delay3
    GOTO Main
    
    
    GetDelay:
      DEBUGIN DEC4 value
    RETURN
    
    
    SetDelay1:
      delay1 = value
    RETURN
    
    SetDelay2:
      delay2 = value
    RETURN
    
    SetDelay3:
      delay3 = value
    RETURN
    
    Print:
      DEBUG CLS, DEC ?delay1, DEC ?delay2, DEC ?delay3, CR, "Processing..."
    RETURN
    
Sign In or Register to comment.