SHARE
TWEET

Untitled

a guest Oct 21st, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def GetStepsRight():
  2.     global Rsteps
  3.     RlastState, Rsteps = 0
  4.     wp.pullUpDnControl(AInput, 2)
  5.     wp.pullUpDnControl(BInput, 2)
  6.     while True:
  7.         AState = wp.digitalRead(AInput)
  8.         BState = wp.digitalRead(BInput) << 1
  9.         RState = AState | BState
  10.         if RlastState != RState:
  11.             if RState == 0:
  12.                 if RlastState == 2:
  13.                     Rsteps += 1
  14.                 elif RlastState == 3:
  15.                     Rsteps -= 1
  16.             elif RState == 2:
  17.                 if RlastState == 3:
  18.                     Rsteps += 1
  19.                 elif RlastState == 0:
  20.                     Rsteps -= 1
  21.             elif RState == 3:
  22.                 if RlastState == 0:
  23.                     Rsteps += 1
  24.                 elif RlastState == 2:
  25.                     Rsteps -= 1
  26.             RlastState = RState
  27.         time.sleep(0.001)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top