Skip to content

Commit cd7e989

Browse files
committed
Lint new example
1 parent e73840a commit cd7e989

File tree

1 file changed

+39
-38
lines changed

1 file changed

+39
-38
lines changed

examples/stepper_motor.py

Lines changed: 39 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,39 @@
1-
# This example uses an Adafruit Stepper and DC Motor FeatherWing to run a DC Motor.
2-
# https://www.adafruit.com/product/2927
3-
4-
import time
5-
6-
from board import *
7-
import busio
8-
9-
# Import the PCA9685 module. Available in the bundle and here:
10-
# https://github.com/adafruit/Adafruit_CircuitPython_PCA9685
11-
from adafruit_pca9685 import PCA9685
12-
13-
from adafruit_motor import stepper
14-
15-
i2c = busio.I2C(SCL, SDA)
16-
17-
# Create a simple PCA9685 class instance for the Motor FeatherWing's default address.
18-
pca = PCA9685(i2c, address=0x60)
19-
pca.frequency = 1600
20-
21-
# Motor 1 is channels 9 and 10 with 8 held high.
22-
# Motor 2 is channels 11 and 12 with 13 held high.
23-
# Motor 3 is channels 3 and 4 with 2 held high.
24-
# Motor 4 is channels 5 and 6 with 7 held high.
25-
26-
pca.channels[7].duty_cycle = 0xffff
27-
pca.channels[2].duty_cycle = 0xffff
28-
stepper_motor = stepper.StepperMotor(pca.channels[4], pca.channels[3], pca.channels[5], pca.channels[6], microsteps=4)
29-
30-
for i in range(100):
31-
stepper_motor.onestep()
32-
time.sleep(0.01)
33-
34-
for i in range(100):
35-
stepper_motor.onestep(direction=stepper.BACKWARD)
36-
time.sleep(0.01)
37-
38-
pca.deinit()
1+
# This example uses an Adafruit Stepper and DC Motor FeatherWing to run a Stepper Motor.
2+
# https://www.adafruit.com/product/2927
3+
4+
import time
5+
6+
from board import SCL, SDA
7+
import busio
8+
9+
# Import the PCA9685 module. Available in the bundle and here:
10+
# https://github.com/adafruit/Adafruit_CircuitPython_PCA9685
11+
from adafruit_pca9685 import PCA9685
12+
13+
from adafruit_motor import stepper
14+
15+
i2c = busio.I2C(SCL, SDA)
16+
17+
# Create a simple PCA9685 class instance for the Motor FeatherWing's default address.
18+
pca = PCA9685(i2c, address=0x60)
19+
pca.frequency = 1600
20+
21+
# Motor 1 is channels 9 and 10 with 8 held high.
22+
# Motor 2 is channels 11 and 12 with 13 held high.
23+
# Motor 3 is channels 3 and 4 with 2 held high.
24+
# Motor 4 is channels 5 and 6 with 7 held high.
25+
26+
pca.channels[7].duty_cycle = 0xffff
27+
pca.channels[2].duty_cycle = 0xffff
28+
stepper_motor = stepper.StepperMotor(pca.channels[4], pca.channels[3], # Motor 3
29+
pca.channels[5], pca.channels[6]) # Motor 4
30+
31+
for i in range(100):
32+
stepper_motor.onestep()
33+
time.sleep(0.01)
34+
35+
for i in range(100):
36+
stepper_motor.onestep(direction=stepper.BACKWARD)
37+
time.sleep(0.01)
38+
39+
pca.deinit()

0 commit comments

Comments
 (0)