Can you use the same pin as input/output and control led load?


Closed Thread
Results 1 to 7 of 7
  1. #1

    Exclamation Can you use the same pin as input/output and control led load?

    I want to confirm if one pin can be an input and later when needed can be made an output and high/low as needed?

    It's just that when an input, it will have 2.5 volt on it through a voltage divider and then I want to inject 5V into the middle point of the voltage divider by making pin an output and toggling it high.

    I am concerned if the pin can be made an output from an input and pushed high, while it already has 2.5v on it continually.

  2. #2
    Join Date
    Oct 2004
    Posts
    440


    Did you find this post helpful? Yes | No

    Default Re: Can you use the same pin as input/output and control led load?

    You can safely toggle a pin high with the output wired to ground or toggle a pin low with the output wired to high as long as their is a 1K resistor (and probably smaller) between the PIC and the wired to high/low.


    Norm
    Last edited by Normnet; - 14th August 2013 at 02:54.

  3. #3
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Re: Can you use the same pin as input/output and control led load?

    Sure. As long as your voltage divider impedance is not too low and if my math isn't too far off...

    Suppose the voltage divider is two 2K Ohms in series for the 2.5V, then the PIC's (approx.) internal 200 Ohm series resistance sourcing 5V will get you a little over 4.5V at the output.

    But if it's two 200 Ohms in series then the output would only be about 3.3V.
    Louie

  4. #4


    Did you find this post helpful? Yes | No

    Default Re: Can you use the same pin as input/output and control led load?

    I think it is better to upload what is in my mind.
    Attached Images Attached Images  

  5. #5
    Join Date
    Nov 2007
    Location
    West Covina, CA
    Posts
    219


    Did you find this post helpful? Yes | No

    Default Re: Can you use the same pin as input/output and control led load?

    To answer your question and your concern,
    Yes, you can monitor that circuit then switch to an output without over driving it.
    Louie

  6. #6


    Did you find this post helpful? Yes | No

    Default Re: Can you use the same pin as input/output and control led load?

    I believe most pic16's and PIC18's have a 20mA source or sink limit so a resistor on the pin would not be required.
    So FromTheCockpit's diagram above will work, though you will not get 5V to feed the LED so you'll need to trim the LED's resistor if you want a brighter LED.

    Also on that note... an LED consumes more than 20mA (~33mA at desired voltage i believe) so... you may not need a resistor on the LED. Instead, if you up the voltage divider resistance values ~ 2K each the LED would not come on but you would still have your /2 voltage divider.

  7. #7
    Join Date
    Dec 2010
    Posts
    409


    Did you find this post helpful? Yes | No

    Default Re: Can you use the same pin as input/output and control led load?

    What are you trying to accomplish with this circuit?
    Is the objective to have the LED on dimly and be able to confirm it has not failed, then be able to have the PIC turn it on brightly or off completely?
    Is the PIC also powered by 5V?
    If so, R3 does not serve any purpose...
    Last edited by Charlie; - 15th August 2013 at 10:30.

Similar Threads

  1. Replies: 1
    Last Post: - 6th April 2007, 11:50
  2. Input / output using same pin
    By leonel in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th March 2007, 22:19
  3. WPU - Input - Output pin triangle
    By sayzer in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 1st July 2006, 12:43
  4. Replies: 1
    Last Post: - 3rd June 2005, 13:17
  5. Using 4 input to control 10 output
    By cibotsan in forum mel PIC BASIC Pro
    Replies: 7
    Last Post: - 5th November 2004, 13:08

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts