Shop OBEX P1 Docs P2 Docs Learn Events
homework board acting weird (very weird) — Parallax Forums

homework board acting weird (very weird)

blink13blink13 Posts: 65
edited 2005-01-31 20:39 in BASIC Stamp
PLEASE help me i tried doing a program that when a button was pushed a light would turn on· and off but whenever my finger gets close to the button the light turns on. This is·with out even touching the button. If how ever i do touch the button (not press it) the light will turn on and stay on untill i touch(not press) the button again this is conflicting with my programming and i dont know wearhter its workin or not please help.
heres my program:

'{$STAMP BS2}
'{$PBASIC 2.5}
DO
IF (IN3 = 1)THEN
·· HIGH 14
ENDIF
·IF (IN3 = 0)THEN
·LOW 14

· ENDIF
LOOP

Comments

  • allanlane5allanlane5 Posts: 3,815
    edited 2005-01-29 14:09
    I'm guessing you don't have a pull-up OR pull-down on your pin 3. Thus it is acting as an antenna. The closeness of your finger is enough to change the noise pattern to a one or zero.

    You need a pull-up resistor (10 Kohms to 25 Kohms) to give your pin 3 a value, when the button is not pressed.
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-01-29 15:09
    Allan is right, you need a pull-up or pull-down on any input.· In your case you could simplify your program by using an active-high input:

    attachment.php?attachmentid=36989

    ... then·write your code like this:

    ' {$STAMP BS2} 
    ' {$PBASIC 2.5} 
    
    Trigger     PIN    3 
    Solenoid    PIN    4 
    
    Reset: 
      LOW Solenoid     ' make output low 
    
    Main: 
      DO 
        Solenoid = Trigger 
      LOOP 
      END
    


    I suspect that you're going to add additional logic to your program -- because as it is you don't need a microcontroller; simply connect the trigger to the solenoid.


    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA
    240 x 201 - 2K
  • blink13blink13 Posts: 65
    edited 2005-01-29 15:51
    oh yeh im going to add other firing modes but thanks
  • blink13blink13 Posts: 65
    edited 2005-01-29 16:02
    ohh i had a few resistors set up like that now it woks thanx
  • blink13blink13 Posts: 65
    edited 2005-01-29 20:49
    oh yeh and what could i do so that when the button is pushed it turns on and off the output or the solenoid to achieve full auto i cant get anything to work
  • Jon WilliamsJon Williams Posts: 6,491
    edited 2005-01-30 01:31
    Perhaps you ought to back up a step ... our book "What's A Microcontroller?" is a great introduction to BASIC Stamp programming.· After you spend some time with WAM, you'd come up with a program like the update I made below:

    ' {$STAMP BS2} 
    ' {$PBASIC 2.5} 
    
    Trigger     PIN    3 
    Solenoid    PIN    4 
    
    IsOn        CON    1 
    IsOff       CON    0 
    
    Reset: 
      LOW Solenoid     ' make output low 
    
    Main: 
      DO WHILE (Trigger = IsOn) 
        Solenoid = IsOn 
        PAUSE 100 
        Solenoid = IsOff 
        PAUSE 100 
      LOOP 
      END
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
    Dallas, TX· USA


    Post Edited (Jon Williams) : 1/30/2005 1:34:11 AM GMT
  • blink13blink13 Posts: 65
    edited 2005-01-31 20:39
    i actually have that book becuase i baught the homework board. I have been doint the projects in it but i kinda skip around.
Sign In or Register to comment.