Opto interrupter

Discussion in 'Programmer's Corner' started by aGpLT, Jun 3, 2010.

  1. aGpLT

    Thread Starter Member

    Jan 21, 2010
    128
    0
    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:

    Code ( (Unknown Language)):
    1.  
    2. ANSEL = 0
    3. OSCCON = $60
    4. TRISB = %00001000
    5. TRISA = %00000000
    6. counts var word
    7. counts = 0
    8.  
    9. loop
    10. count PORTB.3, 20000, counts ' as i understand  it will count 20s.
    11. if counts = 3 then ' if 3 times opto interrupter interrupted then turn on led
    12. high PORTB.4
    13. endif
    14. IF counts = 5 then
    15. high PORTB.5
    16. endif
    17. goto loop
    18. end
    19.  
    i am quite new to programming, sorry if will write nonsenses.

    Language: PicBasic Compiler picbasic pro 2.54
     
    Last edited: Jun 3, 2010
  2. aGpLT

    Thread Starter Member

    Jan 21, 2010
    128
    0
    Someone ? :)

    just updated code, but its not working, i need somehow to get counting in counts register.
     
    Last edited: Jun 3, 2010
  3. aGpLT

    Thread Starter Member

    Jan 21, 2010
    128
    0
    Code ( (Unknown Language)):
    1.  
    2. ANSEL = 0
    3. OSCCON = $60
    4. TRISB = %00001000
    5. TRISA = %00000000
    6. counts var byte
    7. opto var PORTB.3
    8. led VAR PORTB.4
    9. led2 var PORTB.5
    10. counts = 0
    11. if opto = 1 then
    12. counts = counts+1
    13. if counts >=10 THEN
    14. high led
    15. endif
    16. endif
    17. end
    18.  
    tryed this one either :) but nothing. i know i am impatience :x
     
Loading...