Ldr flow chart not working on proto board

Bozambo

Member
I constructed the "LDR SWITCHING" circuit on a PROTO BOARD but for some reason it is just failing to do so.
- see attachment- The Flow chart works perfectly.
WORKING OPERATION
A light source is to strike the LDR placed in a dark box in a sequence namely- Three exposures to the light each exposure lasting approximately 15 seconds ( count from 1 to 30 ).
At the end of the third exposure outputs "0" and "1" should go high for two seconds each in turn after a wait of two seconds

After a time lapse of 120 seconds the sequence resets ie if one exposure is made and more
120 seconds passes the out puts would not go high with two subsequent exposures all because
the event did not take place within the 120 seconds time frame. The System resets ready to start all over again.

WHAT I HAVE DONE SO FAR.
On the PROTO BOARD I have tried both pull up and pull down configurations with the 10K
RESISTOR but it is either not working or working how it is not suporsed to

I tried varying the range of the analogue sensor and again it is either not working or working how it is not supposed to.
As a matter of fact when the LDR is in the uppermost position in the voltage divider without any light exposures the outputs would go high for long periods on its own.

MY SUSPICION
I read somewhere in one of the manuals and it was said that the 10K Resistor is not necessary on the PROTO BOARD but I am not sure.

Secondly I suspect I am missing something that is very fundamental to connecting the circuit.

Any help or advise on resolving the above would be greatly appreciated.
 

Bozambo

Member
This is the Schematic as requested the Proto board is the "Picaxe Proto Board" starter kit AS SOLD BY Rev. Education

SCHEMATIC FOR LDR SWITCHING.JPG
 
Last edited:

nick12ab

Senior Member
C.3 doesn't have ADC. And the ADC-using commands are set to use C.1.
Code:
'Converted on 21/12/2012 at 20:25:08

symbol varA = b0
symbol varB = b1
symbol varC = b2
symbol varD = b3
symbol varE = b4
symbol varF = b5
symbol varG = b6
symbol varH = b7
symbol varI = b14
symbol varJ = b15
symbol varK = b16
symbol varL = b17
symbol varM = b18
symbol varN = b19
symbol varO = b20
symbol varP = b21
symbol varQ = b22
symbol varR = b23
symbol varS = b24
symbol varT = b25
symbol timer = time


let dirsC = %00000111


main:
label_5:
		readadc 1,b9		'read A1 into b9
		if b9 >= 178 AND b9 <= 255 then label_8	'Analogue command
label_6:
		if timer > 120 then label_7	'Compare command
		goto label_5

label_7:
		let varA = 0  	'Expression command
		goto label_5

label_8:	pause 10000	'Wait command
		let varA = varA + 1	'Inc command
		readadc 1,b9		'read A1 into b9
		do while b9 > 178	' repeat
		loop		'End of repeat loop 

		let timer = 0  	'Expression command
		if varA = 3 then label_14	'Compare command
		goto label_6

label_14:	high 0
		pause 2000	'Wait command
		low 0
		high 1
		pause 2000	'Wait command
		low 1
		let varA = 0  	'Expression command
		goto label_6
 

Technical

Technical Support
Staff member
As Nick says, in your circuit you need to switch the ADC onto input4 as input3 does not have an internal ADC at all.
Then in the flowchart select analogue channel A4 for input 4 (A1 for input 1 is currently selected).
 

Bozambo

Member
Thanks a million gentlemen for bringing to my attention my oversight in using pin 3 for an ADC input and it was there all the time just staring at me in the face.I made the necessary adjustments and it is now working perfectly exactly as it is suporse to. Thanks again
Bo
 
Top