Interfacing LDR and Potentiometer

umoharana

Member
I am having problems in iterfacing with a LDR and a potentiometer with 20X2 chip.

I am connecting a LDR to pin c.7 and a potentiometer to b.1

I want to build a logic to compare values of LDR and potentiometer and when LDR > pot I want to trigger a action.

I read that X2 chips require adcsetup before reading the values.

I write the program as below.

adcsetup=%0000000000001010
main: readadc c.7,b0
debug b0
goto main

In the debug panel I see that the value of b0 changes continuously from 184 to 213. At the moment I have connected a pot insted of a LDR.

I can not figure out what is going wrong.

Thanks.
 

hippy

Ex-Staff (retired)
Your code works for me so check you have the pot wired correctly and to the correct leg; leg 3 of a 20X2 for C.7 / ADC3.
 

slimplynth

Senior Member
Looking at manual 1 for the 20X2 pinouts why is there no ADC0.. the ADCSETUP lumps the 20X2 with the 28X2 and 40X2 which do have ADC0... errr double checks..:confused: errr i'm going to the pub.. my head hurts.
 

umoharana

Member
Iterfacing 20X2 with LDR

I have a strange problem. My 20X2 chip's PIN c.7 does not seem to be working. Even if nothing is connected to this pin, its value on debug panels keeps changing from 176 to 214.

Pot connected to other ADC pin b.1 is okay.

Any one has got any answer to this. Is there a way to reset the chip.
I have tried clear memory.

Thanks.
 

hippy

Ex-Staff (retired)
It sounds like there's a possible short to the C.7 pin or tracking somewhere. Perhaps tell us more about your configuration, which boards you are using, and perhaps post a photograph.
 

umoharana

Member
It sounds like there's a possible short to the C.7 pin or tracking somewhere. Perhaps tell us more about your configuration, which boards you are using, and perhaps post a photograph.
I have checked for any possible short to this pin. I am using a strip board for my project. All other PINS are okay. I have desoldered all connections to the track of this PIN. Checked for any solder bridge. Everything is okay. The PIN is isolated.

This is a very strange problem.

Regards,

U. Moharana
 

premelec

Senior Member
I'm a believer in no floating pins that might be inputs... so if you connect the pin to V- does the artifact still appear? [capacitive pickup is the issue...]
 

hippy

Ex-Staff (retired)
You could perhaps post pictures of your circuit board but have you tested the PICAXE on breadboard in a minimal circuit configuration ?

There's no reason pin C.7 should not work so this suggests the PICAXE has either been damaged, or there's a hardware or program error. Beyond the breadboard test the best way to identify the fault may be to swap the PICAXE-20X2 with another and see if that works or not. If the second works the first is likely damaged, if neither work there's likely some wiring error.
 
Top