Shop OBEX P1 Docs P2 Docs Learn Events
serial inputs — Parallax Forums

serial inputs

coldspringscoldsprings Posts: 14
edited 2010-10-05 08:44 in BASIC Stamp
I need one more input for a float switch. I already have a switch and a "go" button hooked up to Din9(p6) and Din10(p7). I have scoured the manual and a few pbasic books to possibly use Din1 to Din6 for my float switch, but haven't found much. I'm not even sure if I can use the shift registor for the float switch, and if I can then i'm not sure how to declare the input pin and such. I tried reversing Dout8 to use as an input but it switches states rapidly while the switch is making contact.

Any input would be greatly appreciated.

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2010-10-05 07:59
    It would help if you explained what Stamp, Stamp board, etc. you have. "Din9" doesn't make much sense without some context.

    If your problem is not enough inputs, a 74HC165 shift register can provide more. There's a section of the StampWorks Manual (Experiment #24) that shows how (here).

    The "switches states rapidly" could be contact bounce or the lack of a pullup or pulldown resistor. Follow the examples in the StampWorks Manual and in the "What's a Microcontroller?" tutorial on the use of switches.
  • coldspringscoldsprings Posts: 14
    edited 2010-10-05 08:44
    I'm using the BS2 #30064 24-pin Basic Stamp with 10 digital inputs and 8 digital outputs and an optional 4 analog outputs.

    The input on the stamp rapidly changes state wether or not I trigger the float switch. my code for the switch looks like:

    ylight pin 10
    float pin 9
    btnwrk var byte

    pause 5
    button float, 0, 200, 20, btnwrk, 0, no_press
    debug "Low fluid"

    no_press:
    do
    pause 1000
    low ylight
    pause 1000
    high ylight
    pause 5000
    loop until float = 0
    goto main
Sign In or Register to comment.