Shop OBEX P1 Docs P2 Docs Learn Events
I/O Pin Double Duty — Parallax Forums

I/O Pin Double Duty

hmlittle59hmlittle59 Posts: 404
edited 2009-06-04 21:21 in BASIC Stamp
Hello All,

Before I try and possibly smoke my BS2 Pin(s), can I hook up a Piezo to a I/O pin to give a chirp when I need it and then change the pin to Input to monitor a push button switch? The Piezo would be in between the 220/10k ohm resistors. My thinking tells me this would be OK!!!


thanks

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
I'M STILL LEARNING SO MUCH...BUT STILL KNOW SO LITTLE!!!

hmlittle59

Comments

  • Mike GreenMike Green Posts: 23,101
    edited 2009-06-04 05:24
    You could. I assume the 10K is a pullup and the pushbutton would ground the 220 Ohm resistor (and the pullup). You could connect the Piezotransducer between the 220 Ohm resistor and either supply voltage (Vss or Vdd). The pushbutton would have to be open for the chirp to work. The 220 Ohm resistor would protect the I/O pin.
  • hmlittle59hmlittle59 Posts: 404
    edited 2009-06-04 06:20
    thanks Mike,

    Would I have to manually set up the pin direction or would the (FREQOUT Piezo, 100, 4000) do that for me, then the (IF SwitchIN = 0 then ...) back to monitoring the switch work. The switch is (NO). The Piezo would be tied to Vss.


    thanks again Mike

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'M STILL LEARNING SO MUCH...BUT STILL KNOW SO LITTLE!!!

    hmlittle59
  • Mike GreenMike Green Posts: 23,101
    edited 2009-06-04 13:13
    I think FREQOUT sets output mode, but I'm not sure if it sets it back to input mode. Just testing the pin value in an IF doesn't set input mode. Check the manual. It's usually clear on this issue. I would use an INPUT statement before the IF.
  • hmlittle59hmlittle59 Posts: 404
    edited 2009-06-04 20:29
    thanks Mike,

    I've down loaded the WAM.2_2 and I will look that up. When you say use a INPUT before the IF statement, will I have to respond to it or is it just to change the PIN direction?

    thanks again

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    I'M STILL LEARNING SO MUCH...BUT STILL KNOW SO LITTLE!!!

    hmlittle59
  • Mike GreenMike Green Posts: 23,101
    edited 2009-06-04 21:21
    Read the description of the INPUT statement. It sets the I/O pin mode to input.
Sign In or Register to comment.