Shop OBEX P1 Docs P2 Docs Learn Events
LED & Rocker Switch detection — Parallax Forums

LED & Rocker Switch detection

hmlittle59hmlittle59 Posts: 404
edited 2014-03-05 18:48 in General Discussion
Hello All,

This is my first time attaching a schematic, so hopefully it will be readable. Lot of notes on the Schematic also.
But basically I'm coming off a BS2e I/O pin thru a 10k & 220 ohm Pull Up combo. At first I had a LED + 470 ohm along with a Rocker On/Off switch connected to short to "GND" when "ON". This may be the best way to go in the long run(over kill), but I wanted to better isolate the I/O pin from the LED with a Transistor switch. I'm using a 2n3906 along with (2) 10k resistors on the BASE & EMITTER(See Attachment). I've tried different Collector / Emitter combinations without the expected results on the "BASE" of Q1(Zero "0" Volts). However I did use the Single PNP trans. Pack like on the BS2's modules but it failed and would turned on my LED when it should have been OFF. I'm now using a PNP 2amp, so no chance of burn out. Just need to get it working. The LED is rated at 20ma and the Q1 was 200ma, don't know why it failed.

Putting this out their for now if anyone has any input or see my oops, or better yet "What the Heck were you thinking", let me know.
Must get sleep now. Will start all over tomorrow.
Thanks again

Howard
PS: Glad I did a "Preview", tried to clear up some areas and forgot to attach .sch
PS: The attachment steps was harsh....wow....what ever happen to just click the "Paper Clip"

Comments

  • T ChapT Chap Posts: 4,223
    edited 2014-03-01 18:39
    You have a voltage divider at your base. So when the switch is pressed, you present 2.5V to the base, when open you will have 5V at the base. Your input should see 5V when open, 0 when pressed. What is the code supposed to be doing and have you seen any result in your code with some method?
  • kwinnkwinn Posts: 8,697
    edited 2014-03-01 20:49
    As the circuit is wired now the led will be on if the switch is closed OR pin RC3 is low, and the led will be off if the switch is open AND RC3 is high. Is this what you want it to do? If so the circuit is a bit more complicated than it needs to be but it should work.

    BTW, the 3906 should not have burned out in that circuit. The .470k resistor would limit the current through the led to less than 8mA. Perhaps you connected the switch directly to the base of the 3906. That would destroy it.

    You will get more help if you explain what you are trying to do with this circuit.
  • hmlittle59hmlittle59 Posts: 404
    edited 2014-03-04 21:30
    Hello All,

    Thanks T Chap and Kwinn for the replies. The circuit is not working as I had hoped. I have Prototypes with copper pour and It's making it harder to T/S. I did get one of the PCB's to work but there is still 3 V across the PNP(Collector) when OFF (5v) on the BASE, so I'll try the Emitter to Base resistor to try and reduce the 3 v. With the 5 V on the other side of the LED, the difference is not enough to turn it on.

    BTW, the 3906 that I thought had burnt out before, very well could of been good like you said Kwinn, its just that it did not shut off all the way. I did have to change the way I applied the GND and 5 V to that part of the circuit. One of my previous PCB's has that dimm LED when it's suppose to be off and it has the old 5v/GND lay out.

    I just tested my original concept again, turning the LED ON an OFF about 50 time and did not fail. I just did not want only a 220 & 470 Ohm resistors between the LED and MC.(SEE Sch.).

    The original concept was to have 5 vdc on both sides of the LED. Then going through a Rocker Switch to GND and a standard Pull UP Switch also connected to the Rocker Switch to GND, when the RS was ON it would shunt both the LED and the Pull UP together to GND. Like I said before, this worked fine but kind of made me nervous with that type of connection. Maybe its been done before....don't know. I know that I've had it running like that here in my home for the pass 3 or 4 years and it still working. Anyway, I'm going to work up another circuit with some SMT and Thru Hole parts to work out all the bugs.

    PS:any more input please let me know. I re did the sch. and will try and attach.
    PS:WOW...It's even worse when your doing a quick reply.....WOWicon8.png
    I think it attached.
  • RDL2004RDL2004 Posts: 2,554
    edited 2014-03-05 08:42
    Put the switch on the high side. When closed it sends 5 volts to the Stamp through the 220R and to the LED through the 470R. When open, nothing.
  • hmlittle59hmlittle59 Posts: 404
    edited 2014-03-05 18:48
    Hello All,

    OOOPS. MY BAD. Trying to give a quick reply before going to bed, I screwed that up, good catch...I corrected the sch.

    Thanks RDL2004 for the reply. R1 & R2 create a Pull Up switch for the MC. When the Rocker Switch is closed(GND), this is detected by the program and displays data to the LCD Screen. Also at the same time the LED that has 5 vdc on both sides and should not come on because of no difference of potential, should now turn ON because of the (GND) to the (Cathode/FLAG) side of the LED.

    Corrected sch. attached.

    my favorite part of this.icon12.png

    OOOPs. Didn't attach:
Sign In or Register to comment.