I am trying to create variable delay using R & C. (using 89S52)
where C is fixed value = 100NF & R is variable 100K resistor.
time range maximum 1 second
attaching my code but not getting success. also Attaching image
Code: Select all
program MyProject
' Declarations section
dim speed as longword
dim i as longword
dim rcin as sbit at P2_7_bit
main:
' Main program
p2 = $00
while true
' Main program
p1 = $ff
gosub delaymy
p1 = $00
gosub delaymy
wend
delaymy:
p2.6 = 1 'send pulse to discharge cap
delay_ms(20) '
p2.6 = 0 'turn off pulse
'as cap will charge rcpin will goes low
'in that time increment one variavle
while rcin = 1
speed = speed + 1
wend
for i = 0 to speed
delay_ms(10)
next i
return
end.