aboutsummaryrefslogtreecommitdiffstats
path: root/System_Python/test_Motor.py
blob: 80cff1e602890d9ef25328fbe35f38b7cc2c5585 (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 motor import Motor
import time

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