Python Forum
EOF error using stepper motor
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
EOF error using stepper motor
#1
Hello,
I'm writing a program to control a stepper motor using keyboard presses and I keep getting an 'EOF' error and I'm not sure how to fix it.


import curses
import time
import RPi.GPIO as GPIO

screen = curses.initscr()
curses.noecho() 
curses.cbreak()
screen.keypad(True)

GPIO.setmode(GPIO.BOARD)

ControlPin = [7,11,13,15]

for pin in ControlPin:
	GPIO.setup (pin, GPIO.OUT)
	GPIO.output (pin, 0)

seq2 = [[1,0,0,0],
	[1,0,0,0],
	[0,1,0,0],
	[0,1,0,0],
	[0,0,1,0],
	[0,0,1,0],
	[0,0,0,1],
	[0,0,0,1],
	[1,0,0,0],]

try:
        while True:   
            char = screen.getch()
            if char == ord('q'):
                break
            elif char == curses.KEY_RIGHT:
                for i in range(512):
                    for halfstep in range(9):
                        for pin in range(4):
                            GPIO.output(ControlPin[pin], seq2[halfstep][pin])
                        time.sleep(0.001)

        GPIO.cleanup()
Reply
#2
please format code with 4 spaces.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  micropython-stepper 1.0.3 trix 2 554 Nov-20-2023, 06:00 AM
Last Post: trix
  Stepper motor/Easy Driver/HELP Harney 1 1,853 Jul-31-2021, 08:05 AM
Last Post: Harney
  python 3 raspberry pi 4 dual control motor programming problem yome 0 1,938 Mar-21-2021, 05:17 PM
Last Post: yome
  stepper motor and servo key control cel 4 2,552 Jul-27-2020, 06:26 AM
Last Post: DPaul
  Stepper Motor key control cel 2 1,863 Jul-25-2020, 12:19 AM
Last Post: cel
  Control 2 stepper motor simultaneously jihene 2 3,962 May-08-2019, 05:27 PM
Last Post: DeaD_EyE
  How to use servo motor with TFMini Distance Sensor in python script? programerguy 1 3,209 Dec-04-2018, 04:57 PM
Last Post: Larz60+
  stepper motor with raspberry pi bowen73 3 4,548 Aug-15-2017, 04:46 AM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020