Shop OBEX P1 Docs P2 Docs Learn Events
Need a little help. — Parallax Forums

Need a little help.

wiresalotwiresalot Posts: 40
edited 2010-07-04 00:02 in BASIC Stamp
My progam is as follows,


DO
dEBUG ? IN 2
DEBUG ? IN 3
DEBUG ? IN 4

IF (IN 4=0) THEN
LOW 14

ELSEIF (IN 3=1) THEN
HIGH 14

ELSE
PUASE 10

ENDIF

LOOP

How do I add another input? I read the docs,

Thanks

wiresalot

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-07-03 14:47
    1) Please don't enter your program this way. Take your actual source file and attach it to your message using the Attachment Manager that you get when you use the Post Reply button rather than the Quick Reply box. If you do it this way, we know what you're actually using (including any formatting you're using). If you must use Cut and Paste, use the [noparse][[/noparse] code ] [noparse][[/noparse] /code ] tags to try to maintain as much formatting as possible.

    2) What do you mean by "add another input"? What do you want the input to do?
  • FranklinFranklin Posts: 4,747
    edited 2010-07-03 14:49
    Could you write out a script of what you want the program to do?
    like :
    if pin 4 low then low 14 loop
    if pin 4 is high and pin 3 is high then high 14 loop
    if pin 4 is high and pin 3 is low then pause 10 loop

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • wiresalotwiresalot Posts: 40
    edited 2010-07-03 16:37
    Will try doing my code that way.

    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
     DO
     DEBUG ? in2
     DEBUG ? IN3
     DEBUG ? IN4
    
     IF (IN4 = 0) THEN
     LOW 14
    
     ELSEIF (IN3 = 1) THEN
     HIGH 14
    
     ELSE
     PAUSE 1
    
     ENDIF
     LOOP
    



    The additional input would make 14 low and 15 high.

    Script for Franklin;

    if pin 4 is low then low 14 low 15 loop
    if pin 3 is high then high 14 low 15 loop
    if pin 2 is high then low 14 high 15 loop

    Thanks for your replies.

    wiresalot
  • Mike GreenMike Green Posts: 23,101
    edited 2010-07-03 21:12
    This is your script expressed in Stamp Basic:
    ' {$STAMP BS2}
    ' {$PBASIC 2.5}
    
     DO
        DEBUG ? in2
        DEBUG ? IN3
        DEBUG ? IN4
       if in4 = 0 then low 14 : low 15
       if in3 = 1 then high 14 : low 15
       if in2 = 1 then low 14 : high 15
    loop
    


    The question is: Is this what you really want?

    What about the relationship between the different switches? What do you want to do if the switches have the opposite setting? Do you want to react to the on-off or off-on transition rather than the switch state?
  • wiresalotwiresalot Posts: 40
    edited 2010-07-04 00:02
    Thanks Mike!

    Thats how i want it to work (for now). So I dont need the ELSEIF and ELSE comands I see.

    I am used to ladder logic/diagrams and wiring them trying to learn how to convert the diagrams
    into code, This program runs like a stop forward reverse motor control circuit.

    I still need to do alot more reading and learning with the Stamp! But I love to learn!

    Thanks again!

    wiresalot
Sign In or Register to comment.