Shop OBEX P1 Docs P2 Docs Learn Events
help with code — Parallax Forums

help with code

agfaagfa Posts: 295
edited 2008-08-03 11:26 in Propeller 1
could someone take a look at the code i have attached, and let me know whats wrong.· i'm sure it's something simple but i've been fighting it for two days now and i can't seem to see the problem.

its supposed to detect a zero to one transition on pin 6.

it appears to me that the statements after the if condition are met, only occurr once.

Comments

  • ColeyColey Posts: 1,110
    edited 2008-07-30 07:11
    Hi agfa,


    Change your if statement to this and it should work....

    if !prevl & newl {left encoder 0 to 1 trans}   
    
    



    compares if pevl is 0 and newl is 1

    Regards,

    Coley

    EDIT:

    I forgot to add, that you also need to make
    prevl := newl
    

    part of the main repeat loop, presently it is only executed as part of the IF statement
    therefore the code would only work once.

    smile.gif

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    PropGFX Forums - The home of the Hybrid Development System and PropGFX Lite

    Post Edited (Coley) : 7/30/2008 7:51:24 AM GMT
  • agfaagfa Posts: 295
    edited 2008-08-03 11:26
    thanks Coley,

    changing the location of the "prev1 := newl" got it working. i never would have thought of the if statement you suggested. nice. if anyone needs the most complicated way to do a simple task, just ask me.
Sign In or Register to comment.