Shop OBEX P1 Docs P2 Docs Learn Events
Is this safe? RC Time to detect ON/OFF — Parallax Forums

Is this safe? RC Time to detect ON/OFF

Luis_PLuis_P Posts: 246
edited 2012-03-08 15:07 in BASIC Stamp
Hi, I need to know if my setup will not damage the Bs2 or my Mp3 player. I needed to detect when a song start playing on my Mp3 player. The player board has an LED that is ON when the song starts, I soldered one leg of the LED to pin 1 (bs2) and ground (mp3 player) to ground (5V- bs2). Everything work perfect with the code below, when reads 1 “do something”, when reads 0 do something else. Is working! But how long will last? It will damage either the pin or the LED on Mp3 player board?
GRACIAS!

Code:

X var word
dirs =$ffff ‘ do I need this?

DO
pause 500
RCtime 1,0,X
low 1
IF X = 0 goto routine1
IF X = 1 goto routine2
LOOP

connections:

BS2 pin 1
LED mp3 player (only one side, do know if cathode or anode the LED is surface mounted)
BS2 VSS
GND ( is the ground connection on the mp3 player board)

Comments

  • ZootZoot Posts: 2,227
    edited 2012-03-08 12:26
    This is not good as it sets all pins to outputs, which can short your Stamp pin (both the LED pin and the Stamp may try to drive the connection at the same time).

    Also, why are you using RCTIME? Why not just see if the pin (as an input) is high or low? I would also put a 220ohm or so resistor between the LED pin at the Stamp pin to protect the Stamp in the event the pin is made an output (inadvertently).
  • Luis_PLuis_P Posts: 246
    edited 2012-03-08 14:44
    Can I keep the same code but remove the DIR $ffff ? that's the statement that sets all pins to output, do I need
    that to keep using the RC-Time code?
  • ZootZoot Posts: 2,227
    edited 2012-03-08 15:07
    Well, RCTIME requires the pin to be flipped from output to input, so that the RC circuit can be charged/discharged. Not sure you need RCTIME for this, when you could just check if the pin is high or low. But in either case, I would still put a low value resistor between the Stamp pin and the LED pin to prevent possible shorts if/when the Stamp pin is an output.
Sign In or Register to comment.