Reader small image

You're reading from  Practical Python Programming for IoT

Product typeBook
Published inNov 2020
Reading LevelIntermediate
PublisherPackt
ISBN-139781838982461
Edition1st Edition
Languages
Right arrow

Running and exploring the stepper motor code

The code we are about to run can be found in the chapter10/stepper.py file. I recommend reviewing the source code before proceeding so that you have an overall idea of what the file contains.

When you run the code found in the chapter10/stepper.py file, your stepper motor should rotate a complete 360 degrees in one direction, and then back again.

Place a piece of tape on the shaft of your stepper motor to make it easier to see when it rotates and in what direction.

Starting at the top of the source file, we define all our GPIO variables, including our enable pins at line 1, plus variables starting at line 2 relating to our stepper motor coil wires. These wires must be identified and ordered correctly, as coil wire order matters!

CHANNEL_1_ENABLE_GPIO = 18                                # (1)
CHANNEL_2_ENABLE_GPIO = 16

INPUT_1A_GPIO = 23 # Blue Coil 1 Connected to 1Y # (2)
INPUT_2A_GPIO = 24 # Pink Coil 2 Connected...
lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Practical Python Programming for IoT
Published in: Nov 2020Publisher: PacktISBN-13: 9781838982461