Connect with us

Double functionality on Micro

Discussion in 'Microcontrollers, Programming and IoT' started by Rajinder, Dec 8, 2019.

Scroll to continue with content
  1. Rajinder

    Rajinder

    419
    7
    Jan 30, 2016
    Hi all,
    I have a issue where due to lack of i/o lines i need to double up on one i/o line. As an A/D to read light sensor and output to drive the LED.
    The light sensor output should go from 0 to 2.7V. However, it is being clamped to around 2V (forward volt drop of LED) i think it may be due to the 220R and leakage current of the LED.

    My possible solution was to use an Zener instead of the 220R or a diode instead of the 220R. I have no other i/o lines available.

    Any help would be appreciated.
    Thanks in advance.
     
  2. Rajinder

    Rajinder

    419
    7
    Jan 30, 2016
    I wil upload a schematic too.
     
  3. Rajinder

    Rajinder

    419
    7
    Jan 30, 2016
    Here is the schematic.
    any help would be appreciated.
     

    Attached Files:

  4. Harald Kapp

    Harald Kapp Moderator Moderator

    9,544
    1,970
    Nov 17, 2011
    This will not work.
    The 33 kΩ resistor will reduce the current through the LED to a mre 100 µA (assuming a 3.3 V output pin.

    There are better options to increase the numbe rof available I/O lines. E.g. use a shift register to serially output a number of bits using only 2 wires (data and clock). Or use an I/O-expander, e.g. one of those offered here.
    I recommend that you do not mix analog functionality and digital functionality as this may have consequences with regard to signal integrity that are hard to fix.
     
    bertus likes this.
  5. Rajinder

    Rajinder

    419
    7
    Jan 30, 2016
    The 33K was used to stop the LED working when measuring current..
    When it is a output it lights very briefly to flash every 1 minute.
    Would putting a diode in place of the 220R help? Or a zener diode?
    The only other thing i was thinking was to use a i/o expander as you mentioned. However i really am restricted by PCB space.
    Any other suggestiins?
     
  6. bertus

    bertus

    256
    82
    Nov 8, 2019
    Hello,

    What micro are you using?
    What is on the other I/O lines of the micro?

    Bertus
     
  7. Rajinder

    Rajinder

    419
    7
    Jan 30, 2016
    Hi
    The other pins are used for push buttons, LEDs, analogue inputs and buzzers.
     
  8. Rajinder

    Rajinder

    419
    7
    Jan 30, 2016
    Its a PIC16F1938..
     
  9. bertus

    bertus

    256
    82
    Nov 8, 2019
  10. Rajinder

    Rajinder

    419
    7
    Jan 30, 2016
    I have 2 buttons, the leds are already multiplexed.
    I think it may come down to using a shift register, this would mean trying to free up 3 i/o lines, clk, data and latch.
    Which i cant afford to do.
     
  11. bertus

    bertus

    256
    82
    Nov 8, 2019
  12. Rajinder

    Rajinder

    419
    7
    Jan 30, 2016
    I have 2 backlights for a lcd and 1 extra led. Trying to connect from 2 i/o lines. Lcd have common anodes
    They all have to work independently.
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-