aboutsummaryrefslogtreecommitdiffstats
path: root/System/test_Encoder.py
blob: bb6e3e40447faa7e93906fa320b5dba6ce54584e (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 encoder 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()