aboutsummaryrefslogtreecommitdiffstats
path: root/System/Tests/test_Encoder.py
blob: fa1c91c95ec0fbafd2f29a01eda5a4083da3eada (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from pendulum import Encoder
import time
import RPi.GPIO as GPIO

# Decide which pins to hook up to on the Pi before running
clk_pin = 3
cs_pin  = 23
data_pin = 2

e = Encoder(clk_pin, cs_pin, data_pin)
e.set_zero()

try:
    while(1):
        print(e.read_position('Degrees'))
        time.sleep(0.001)
except:
    print("Program killed by Ctrl-C")
finally:
    # Perform GPIO cleanup. Things may get weird otherwise...
    GPIO.cleanup()