Quote Originally Posted by rossfree View Post
Hi all,

I'm having a bit of trouble getting my a/d working just right. I have an LM34 connected to GPIO.0 and a pot feeding 2.55 volts to Vref pin GPIO.1

I am trying to turn on a relay connected to GPIO.5 based on the temperature reading.h

I don't think I have the a/d bits set correctly. It appears to still think it is 10 bit but I want it set to 8.

Can you please look at my short code and tell me where I have gone astray.

If you look at the txt file attached, you'll note that I have the relay turning on when my a/d result is > 330.

By measuring the voltages and doing some math... that's right where it would be if the A/D was 10 bit. And it does work. The relay turns on and off when I touch the temperature sensor.

Help please! :-)

Thank you!

Ross
Left justify the A/D result, use the high A/D result byte for your end result and ignore the lower 2 bits at the top of the lower A/D result byte.
You'll lose 2 bits of resolution, but you'll only deal with a single byte.