aboutsummaryrefslogtreecommitdiffstats
path: root/System/Tests/test_Motor.py
blob: f48b6eed10f5362f56787a85a241786e71956778 (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
24
25
26
27
28
29
from motor import Motor
import time
import RPi.GPIO as GPIO

# Decide which pins to hook up to on the Pi before running
speed_pin = 17
forward_pin = 27
reverse_pin = 22

m = Motor(speed_pin, forward_pin, reverse_pin)

dir = 'ascending'
speed = 0.0
try:
    while 1:
        if speed >= 15.0:
            dir = 'descending'
        elif speed <= -15.0:
            dir = 'ascending'
        if dir == 'ascending':
            speed = speed + 2.0
        else:
            speed = speed - 2.0
        m.move(speed)
        time.sleep(0.1)
except:
    print("Program killed by Ctrl-C")
finally:
    GPIO.cleanup()