Using a IR photoresistor as a switch.

I got a upcomming project

I have a IR transistor that I will use as a switch. I would rather not use a schmidttrigger but instead use a analog pin.(or digital)

Right now im using the IR transistor an reading on an analog pin. I would like this to act as a switch that turns low when my adc is < 100 and turn high when my adc is >150.
For this timing is essential, so I cannot use the adc. (I need the change to be maped as accurate as possible).

Any sugestions? Would I be better off using a schmidttrigger and a digital pin that triggers an interrupt on change?



Look into the analog comparator function of the chip. You can set the threshold that an analog voltage must cross to generate an interrupt.

I'm confused about what it is you want to do.

  • What do you want to switch?
  • How fast do you need to switch whatever it is you're switching?

I understand you say as accurate as possible, but that's not really a practical definition...

The ADC is pretty fast, check out this discussion: Reading directly from the port may be faster as well, check out this discussion:

(I know there are better instructions on doing the direct port manipulating floating around, you'll have to google it yourself if you're interested.)

Chances are, however, that the ADC is actually fast enough as is (in my own experience, everytime I thought the conversion was too slow, I realized the actual bottleneck was somewhere else.)

In regards to the switching thing: in theory you can use the photo-transistor as a switch. Without knowing what you're switching, its hard to give you any suggestions.