Shop OBEX P1 Docs P2 Docs Learn Events
very basic question for beginner — Parallax Forums

very basic question for beginner

timparrishtimparrish Posts: 2
edited 2011-06-14 13:12 in BASIC Stamp
I am brand new to microcontrollers and programming. I have the "What's a Microcontroller?" book and am going through it. In the Digital Input - Pushbuttons section (chapter 3) I tested my pushbutton and it appears to work fine, but when I hook it up to the Basic Stamp I cannot get it to function the way it does in the book. The first activity is a very basic setup that is suppose to display in the Debug Terminal the state of the BS2 Input (1 or 0). The code is:
PAUSE 1000

DO

  DEBUG ? IN3
  PAUSE 250

LOOP
The setup is:
Vdd ---> pushbutton (pb) pin1; pb pin2 ---> 200ohm ---> BS2 P3; pb pin3 ---> 10k ohm ---> Vss.

In theory I'm suppose to see a 1 when the button is pressed and a 0 when not. In actuality, I see a 0 when not pressed and get nothing in the Debug Terminal when it is pressed.

Help would be greatly appreciated.

Comments

  • Tracy AllenTracy Allen Posts: 6,662
    edited 2011-06-13 14:35
    That would happen if the pushbutton short circuits the power supply or holds the Stamp in reset. You can eliminate that theory by adding one line at the top of your program before the PAUSE:
    DEBUG "top",CR
    If you see that every time you press the button, then the Stamp is resetting.
    With the program as given, there is no other way that I can think of that it would show nothing at all when the button is pressed.
  • timparrishtimparrish Posts: 2
    edited 2011-06-13 20:27
    Thank you. I added that line and discovered that it is resetting when I press and release the button. Now I just have to find out where the short is... :depressed:
  • ercoerco Posts: 20,256
    edited 2011-06-14 13:12
    Probably near where the smoke is coming from... :)
Sign In or Register to comment.