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

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

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()