Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] How to turn LED on and off when it's connected negative to pin?

Status
Not open for further replies.

Windmiller

Member level 4
Joined
Mar 30, 2010
Messages
76
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
Sweden
Activity points
1,997
Hello!

This is just an example..
Lets say that I want the PIC to flash a LED on and off when the negative pin is connected to the PICs output pin. Can I do this without using a transistor?
So, what I'm asking for is if it's possible to completely disable a pin from both positive and negative currency programatically to make this connection flash.

Regards

/ Morgan
 

hi!
I think you are actually trying to put a diode after the PIC output.

PIC just gives two logic levels 1 and 0; which are generally 5V volts and 0V. so if you see it theoratically then you have to apply a potential higher than 5V on the other pin(+ve) of the LED which will drive it. But this have to appear only when PIC gives logic 1 otherwise the LED will keep on glowing.
This can be possible by using the OP-Amp comparator config. or in other case you have to use transistor to drive LED.
Programaticaly you can just get 0 or 1;
 
Thank you Habib!

So, the basic version of this is to basically just add a diode between the PIC pin and LED pin and send a positive 1 out from PIC when I want the LED to be off and a 0 when I want it to be on?

/ Morgan
 

So, the basic version of this is to basically just add a diode between the PIC pin and LED pin and send a positive 1 out from PIC when I want the LED to be off and a 0 when I want it to be on?

If you use a diode in between PIC and LED then no operation will be performed.
Use led direct with PIC pin,but be sure the voltage you are applying to the led not exceed 5v,

Best regards
 

There is two way to turn ON & OFF the LED.
1. By using External current limiting resitor in series with LED & connect to microcontrollerwhich will give high & low signal to LED for turn ON & OFF.
2. Directly connect LED to microcontroller & give PWM pulse to turn ON the LED just make sure that Duty cycle is not more.For turn off give low signal (0v) to LED.


Regards
Chanchal Chauhan
 

If you use a diode in between PIC and LED then no operation will be performed.

Yes, the diode is not needed.
The Led in itself is a diode, so it will have the same result either way.

Use led direct with PIC pin,but be sure the voltage you are applying to the led not exceed 5v,
Best regards

But how is this going to make the LED flash?
Please don't laugh now.. If I connect the LED to +9V to a 330Ω resistor followed by a LED. The LED voltage is 3 volt and 20 mA This must mean that the PIC pin will have something near +3V which is lower than/and will not exeed +5V. Maybe that I'm wrong, because my electric skill are not soo good.. I'm a programmer trying to learn this part too. :)

Code:
______
|     |_.          //
| PIC |_.---------|<|-----|330Ω|------ +9V 
|     |_.         LED
|     |_.
|_____|

Did I get it right?

/ Morgan

---------- Post added at 12:51 ---------- Previous post was at 12:40 ----------

There is two way to turn ON & OFF the LED.
2. Directly connect LED to microcontroller & give PWM pulse to turn ON the LED just make sure that Duty cycle is not more.For turn off give low signal (0v) to LED.

Chanchal.
This is breaking my head.. I can't see how this will be done with PWN pulse? To turn it off by giving it 0V? Didn't you mean near to 0V but still over zero. Otherwise.. wouldn't the pin on the PIC be GND for the LED and turn it on again?
I had never done anything with PWN pulses yet in my life, only read about it.

/ Morgan
 

Why are you using a 9v source for the LED? Is there a reason you cannot use 5VDC, which is probably available from the PIC supply.

Code:
______
|     |_.          //
| PIC |_.---------|<|-----|100Ω|------ +5V 
|     |_.         LED
|     |_.
|_____|

Now when the pin is high (+5V), there will be no voltage through the LED and resistor. When the pin is low, the 100Ω resistor will limit the current and the LED will light.
 
Why are you using a 9v source for the LED? Is there a reason you cannot use 5VDC, which is probably available from the PIC supply.

Code:
______
|     |_.          //
| PIC |_.---------|<|-----|100Ω|------ +5V 
|     |_.         LED
|     |_.
|_____|

Now when the pin is high (+5V), there will be no voltage through the LED and resistor. When the pin is low, the 100Ω resistor will limit the current and the LED will light.

Thank you, you made it all clear to me! :)

And I was wrong before, I will not lower the voltage to the PIC pin only the I. Volt will still be +9V on the PIC pin.

Thanks alot all of you

/ Morgan
 

Simply for flashing the LED you toggle the output of your port.

As djsfantasi said when you high the output pin,the led will OFF and when low the output pin the led ON.

Best Regards
 

Yes thanks, finally I get it! :)

But I have one more question when it comes to the VDD pin on the PIC that should have +5V and maximum current of 250 mA. Is it possible to connect +9V to this pin without burning the darn thing, by adding a resistor to bring down the currency with this calculation: (+9V-+5V) / 0,250A = R = atleast 16Ω Is this workable or will it still break the PIC?

Regards

/ Morgan
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top