If you're going to post python code on here you need to use [code] ... your code goes here ...[/code] tags. That gets the code formatted correctly with left hand whitespace. I've fixed your code.Code:
from gpiozero import OutputDevicefrom time import sleep# I am using pins 20 and 21.STEP_PIN = 20DIR_PIN = 21step = OutputDevice(STEP_PIN)direction = OutputDevice(DIR_PIN)def move_motor(steps, direction_state): direction.on() if direction_state == 'forward' else direction.off() for _ in range(steps): step.on() #sleep(0.0035) # Delay to control step speed Full sleep(0.0017) # Delay to control step speed 1/2 #sleep(0.0009) # Delay to control step speed 1/4 step.off()# 880 steps seems to be the full range to move the armprint("Moving forward...")move_motor(880, 'forward')sleep(1) # Wait for a momentprint("Moving backward...")move_motor(880, 'backward')
It makes the difference between
If "tags" not = "used":
print ("code is scrambled")
else:
print ("code is perfectly formatted")
And
Code:
If "tags" not = "used": print ("code is scrambled")else: print ("code is perfectly formatted")
Statistics: Posted by DougieLawson — Mon Dec 30, 2024 6:25 pm