Shop OBEX P1 Docs P2 Docs Learn Events
Really basic question — Parallax Forums

Really basic question

HankHank Posts: 2
edited 2008-11-30 10:11 in BASIC Stamp
I have a really basic question. I have a BOE with a BS2 and I have connected a LED between P0 and Vdd. When I run the following example code.......

' HIGH_LOW.BS2
' This simple program sets I/O pin 0 high for 1/2 second and low for
' 1/2 second in an endless loop. Connect an LED to P0 for a simple
' blinker.

' {$STAMP BS2}

Main:
DEBUG "Setting HIGH 0"
HIGH 0
PAUSE 5000
DEBUG "Setting LOW 0"
LOW 0
PAUSE 5000
GOTO Main
END

In my debug window I see "Setting HIGH 0" and the LED goes off, then "Setting Low 0" and the LED goes on. Also with a multimeter I get 0 volts across P0 and Vdd after the "Setting HIGH 0" and 5v after the "Setting Low 0".

The Command Reference manual states in the "HIGH" section "The HIGH command sets the sepecified pin to a 1 (a +5 volt level)"

Now I am confused.

Thanks

Hank

Comments

  • P!-RoP!-Ro Posts: 1,189
    edited 2008-11-29 19:02
    Depends on if it's connected to vdd or vss. Vdd= positive, so when you program it to go "high," both pins would be positive and there would be no flow of current. However, when it is "low," power flows from the pin to vdd. To change this, just connect the led to vss.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Pi Guy
  • HankHank Posts: 2
    edited 2008-11-29 19:10
    Yes - that was it. I obviously have to do a LOT more reading but one has to start somewhere.

    Thanks a lot.

    Hank
  • Carl HayesCarl Hayes Posts: 841
    edited 2008-11-30 10:11
    Another way of saying it is that with the meter you are measuring the difference between the voltages at two points. If one of these (Vdd) is always +5v, and the other is changing between +5v and 0v, then when they're both +5v you measure zero, and when one of them (the output pin) is 0 and the other (Vdd) is +5, the difference you measure is -- guess what -- 5v.

    Always remember that a voltage -- any voltage -- is a DIFFERENCE in potential between two points, one of which is often the circuit's GROUND. But you're measuring between Vdd and the output pin, and neither of these is ground, although the output pin gets reasonably close to ground when it's LOW.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    · -- Carl, nn5i@arrl.net
Sign In or Register to comment.