RCTIME code problem
Carlo
Posts: 23
Could someone help me with this cose please. The problem is where I an LED should light when the value for RCTIME is less than 20000. The lead does turn on and off but not when it goes over or under 20000.
thanks
Carlo
This is the code:
RC············· PIN···· 14
result········· VAR···· Word
Main:
· DO
··· HIGH RC···························· ' charge the cap
··· PAUSE 1···························· '·· for 1 ms
··· RCTIME RC, 1, result··············· ' measure RC discharge time
··· DEBUG HOME, DEC result············· ' display value
··· IF (result<20000) THEN
····· HIGH 15
··· ELSE
····· LOW 15
··· ENDIF
··· PAUSE 500
· LOOP
· END
thanks
Carlo
This is the code:
RC············· PIN···· 14
result········· VAR···· Word
Main:
· DO
··· HIGH RC···························· ' charge the cap
··· PAUSE 1···························· '·· for 1 ms
··· RCTIME RC, 1, result··············· ' measure RC discharge time
··· DEBUG HOME, DEC result············· ' display value
··· IF (result<20000) THEN
····· HIGH 15
··· ELSE
····· LOW 15
··· ENDIF
··· PAUSE 500
· LOOP
· END
Comments
··········· I believe the error is that the prior values are not being cleared. Try the debug line below.
·
··· DEBUG CLS,DEC result············· ' display value
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Stephen Swanson
Technical Support
Parallax, Inc.
sswanson@parallax.com