aboutsummaryrefslogtreecommitdiffstats
path: root/System_Python/test_Motor.py
blob: 99db5202b2e4e9eda07b1263bfd4ac959e454c6d (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:
    m.move(speed)
    if speed >= 100.0:
        dir = 'descending'
    elif speed <= -100.0:
        dir = 'ascending'
    if dir == 'ascending':
        speed = speed + 0.5
    else:
        speed = speed - 0.5
    time.sleep(0.1)