1

I have attached an image of my setup. Code I am using is below

import RPi.GPIO as GPIO
from time import sleep

# Direction pin from controller
DIR = 10
# Step pin from controller
STEP = 8
# 0/1 used to signify clockwise or counterclockwise.
CW = 1
CCW = 0

# Setup pin layout on PI
GPIO.setmode(GPIO.BCM)

# Establish Pins in software
GPIO.setup(DIR, GPIO.OUT)
GPIO.setup(STEP, GPIO.OUT)

# Set the first direction you want it to spin
GPIO.output(DIR, CW)

try:
    # Run forever.
    while True:

        """Change Direction: Changing direction requires time to switch. The
        time is dictated by the stepper motor and controller. """
        sleep(1.0)
        # Esablish the direction you want to go
        GPIO.output(DIR,CW)

        # Run for 200 steps. This will change based on how you set you controller
        for x in range(200):

            # Set one coil winding to high
            GPIO.output(STEP,GPIO.HIGH)
            # Allow it to get there.
            sleep(.002) # Dictates how fast stepper motor will run
            # Set coil winding to low
            GPIO.output(STEP,GPIO.LOW)
            sleep(.002)

Dictates how fast stepper motor will runenter image description here

2
  • So what happened? Did the NEMA 17 guy explode?
    – tlfong01
    Jul 11, 2022 at 2:20
  • Having trouble with my Nema 17 stepper motor ... what trouble?
    – jsotola
    Jul 12, 2022 at 1:04

2 Answers 2

0

As far as I can tell you have white connected to a Pi ground (pin 14) and grey to GPIO 23 (pin 16).

The code is using BCM numbering and GPIO 8 (pin 24) and GPIO 10 (pin 19).

https://pinout.xyz/

0

Apart from Joan's observation, I'd advise you to avoid Dupont connections to join cables. Alot of my projects had them as the culprits in not having proper connections.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.