EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / Please help in reading digital output of IR sensor

Please help in reading digital output of IR sensor

|

Microcontroller › 8051 › Please help in reading digital output of IR sensor

  • This topic has 9 replies, 3 voices, and was last updated 13 years, 12 months ago by AJISH ALFRED.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • June 1, 2012 at 2:32 pm #1829
    Mach
    Participant

    Hi, all.

     

    I have successfully used ADC0804 to convert the analogue input of an IR obstacle sensor in to digital form and display the same on an LCD display.

     

    My problem is that, the IR sensor that I have also gives me digital output. I want to use this output using Atmel AT89S52 microcontroller and display the same on the LCD display. The sensor gives me analogue output from one pin as well as digital output from another pin. The other two pins the sensor has are 5V Vcc and GND.

     

    Please help regarding this as I’m a newbie to the microcontroller world. Thanks in advance.

    June 1, 2012 at 5:38 pm #7949
    AJISH ALFRED
    Participant

     

    Hi Mach,

     

    I understood that you’ve displayed a value on the lcd screen which is the voltage you are getting from the analog pin of your IR sensor. The same can’t be done with your digital pin, as the digital pin basically have only two voltages, one for logic0 and other for logic1.

    I’ve little idea about the sensor you are using, please share the part number or a link to the datasheet.

    June 1, 2012 at 6:44 pm #7951
    Mach
    Participant

    Hi, thank you for your interest. The sensor is an Infrared Obstacle detection sensor with four pins, namely: Vcc(5V), GND, Digital out & Analog out. It can detect obstacles up to 30 cm.

    June 1, 2012 at 8:12 pm #7952
    Mach
    Participant

    Sorry for my mistake people. I just went through the datasheet got to know that the digital output is of just 1 bit ( a logic 1 or 0)  and NOT 1 byte as in the case of analog output.

    My project involves measuring the distance of the obstacle, which I was able to do, but not exactly the result that I wanted.

    The thing is that reading becomes high as the obstacle gets nearer to the sensor. But I want the opposite to be happening. That is the reading should become 0(zero) when the obstacle is closest to the sensor and almost 255 (since the analog output is 8-bit)  when the obstacle out-of-range for the sensor.

    Any help in solving this is much appreciated in advance.

    The datasheet is at this link:- http://probots.co.in/index.php?main_page=product_info&cPath=9&products_id=9

    June 2, 2012 at 1:43 pm #7953
    Amrith
    Participant

    Hi Mach,

     

    Use NOT Gate(74LS04/74HC04) to get your desired result or else simply you can use a transistor(npn).

     

    June 2, 2012 at 5:05 pm #7955
    AJISH ALFRED
    Participant

    You can use a transistor,

     

    Select a npn transistor, BC548

                          

                             _______________________________

           GND<


    |emitter         base         collector|


    > 10k resistor


    > VCC

                             _______________________________

                                                   ^                              |

                                                    |                               |

                                                    |                               |

                                                                                    |_____ output to mcu’s adc

                                        resistor >= 10k

     

                                                    |

                                                    |

                                      your Input from

                                             IR sensor

     

    Also you can simulate it in your code, before displaying on the lcd just do it like

    255 – value from adc !

    June 4, 2012 at 2:49 pm #7967
    Amrith
    Participant

    Hi MACH,

    Use the below circuit

    wysiwyg_imageupload:4844:

    June 21, 2012 at 1:44 pm #8102
    Mach
    Participant

    Thank you guys for your suggestion. Its working fine now, all because of your suggestions.

    June 21, 2012 at 1:56 pm #8103
    Amrith
    Participant

    Hi Mach,

    You are welcome. Post your qureies & experience further.

    June 22, 2012 at 1:50 am #8110
    AJISH ALFRED
    Participant

     

    You are welcome Mach. If you’ve any further doubts, we are here to help you !

  • Author
    Posts
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • Replacement IGBT for DGG4015 for Honda Motorcycle ECU June 14, 2026
  • Mitsubishi Electric IPM module lot code format - how to decode? June 14, 2026
  • TDK Lambda ESS 500-20-11-D-LB-RSTL Parallel Operation June 13, 2026
  • Programmable 1kV DC Power Supply – Budget ~$600 with Display June 13, 2026
  • effect of calibration on s-parameters June 13, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise