Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Reading Port Pins

Status
Not open for further replies.

wuchy143

Member
Hi All,

This may be a dumb question......Is it standard practice that when you want to read either a 1 or a 0 from a port pin that an A/D must be used?
 
Hi All,

This may be a dumb question......Is it standard practice that when you want to read either a 1 or a 0 from a port pin that an A/D must be used?

If you want to read either a 1 or a 0 from an input pin, you simply have the external hardware set the input high or low, then read the input pin. The most common way of doing this is to use a pull up resistor between the input pin and the positive side of the supply, then use a switch to ground the input pin to input a 0 and unground the input pin to input a 1. You can even use a transistor with the collector/emitter junction between the input pin and ground, then use a digital source to pulse the base of the transistor high and low.

If the source of said input is an analog source, then an A/D converter must be used.
 
Last edited:
...
If the source of said input is an analog source, then an A/D converter must be used.

But not if all you want to do is quantize it to a 1 or a 0. An input set to digital mode will have a trip point of ~2V. Crude, but works.

If you want a programmable trip point, then use an analog comparator (not all PICs have these).
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top