# Analog Sensor with digital input?

Discussion in 'The Projects Forum' started by chrispedersen, Sep 15, 2013.

1. ### chrispedersen Thread Starter New Member

Aug 23, 2013
12
0
I have a TI cc2540 to which I would like to attach a variety of photoresistors.

The cells resistance decreases with light intensity. I would like to trigger a specific action when the resistance decreases past a certain threshold.

I am already using the analog inputs on the device for other purposes. Yet it occurs to me that it might be possible to use the pwm digital inputs as all I am trying to accomplish is a simple on/off type activity.

(Yes, I know I could use an ADC for this purpose, however I am trying to minimize chip count and cost. )
The range on the photo resistor is 135 Ohms to 350 ohms.

The circuit runs off 3.2 V, the digital inputs are pwm. Is this possible? How might it be accomplished?

2. ### MrChips Moderator

Oct 2, 2009
17,550
5,450
Ideally, you want to create a voltage divider using the analog sensor and a resistor. The output of the voltage divider should be connected to an analog comparator to create a digital output.

Many Microcontrollers have such a comparator already on the chip which you can use.

You may simply connect the output of the voltage divider to a digital input for your purposes. The drawback of doing so is that the power consumption of a CMOS input gate increases when the input voltage is in the linear region which happens to be your threshold.

An improvement would be to use a Schmitt trigger gate before the input.

Note that every input is a 1-bit ADC.

chrispedersen likes this.
3. ### chrispedersen Thread Starter New Member

Aug 23, 2013
12
0
So, with under coin cell battery operation,
with a resistance range of 135 - 350 Ohm on the photoresister,

Vin --- PhotoResistor
|
--- Vout
|
R2
|
Grnd

If R2 is 35 Ohms, and if I read right the threshold voltage is .5 for the CC2540.

So, if R1 goes from 135 - 350, with this circuit the voltage would transition below .5 at around 170 Ohm resistance on the photo cell.

Do I need to worry about clock cycles, or how the logic circuit is going to read that value? Do I need to worry about impedance?