Opto interrupter

Thread Starter

aGpLT

Joined Jan 21, 2010
128
Hello everyone, the main idea is to count not how fast my motor is going but to get him drive some time. I am using opto interrupter now i only try to do this on my breadboard with LED's but unsuccessfully. Here is my program:

Rich (BB code):
ANSEL = 0
OSCCON = $60
TRISB = %00001000
TRISA = %00000000
counts var word
counts = 0

loop
count PORTB.3, 20000, counts ' as i understand  it will count 20s.
if counts = 3 then ' if 3 times opto interrupter interrupted then turn on led
high PORTB.4
endif
IF counts = 5 then
high PORTB.5
endif
goto loop
end
i am quite new to programming, sorry if will write nonsenses.

Language: PicBasic Compiler picbasic pro 2.54
 
Last edited:

Thread Starter

aGpLT

Joined Jan 21, 2010
128
Someone ? :)

ANSEL = 0
OSCCON = $60
TRISB = %00001000
TRISA = %00000000
counts var word
opto var PORTB.3
led VAR PORTB.4
led2 var PORTB.5
counts = 0

loop
IF opto = 0 then
low led
endif
if opto = 1 then
high led
endif
if led = 1 then
counts = 0+1
endif
if counts = 10 then
high led2
endif
goto loop
end
just updated code, but its not working, i need somehow to get counting in counts register.
 
Last edited:

Thread Starter

aGpLT

Joined Jan 21, 2010
128
Rich (BB code):
ANSEL = 0
OSCCON = $60
TRISB = %00001000
TRISA = %00000000
counts var byte
opto var PORTB.3
led VAR PORTB.4
led2 var PORTB.5
counts = 0
if opto = 1 then
counts = counts+1
if counts >=10 THEN 
high led
endif
endif
end
tryed this one either :) but nothing. i know i am impatience :x
 
Top