Here is a simple project that only needs a raspberry pi, pi face, python, jumper wires, and a stepper motor-that's it!
Step 6:
Sixth type this into a python file (or copy-paste):
#CONTROLLING A STEPPER MOTOR #Author: Robert Caldwell #Date: 14 August 2013 from time import sleep import piface.pfio as pfio pfio.init() print"Type: direction(rotations, speed)" def anticlockwise(rotations, speed): sleep_time=0.1 / float(speed) for loop in range(1,int(512*float(rotations))): pfio.digital_write(4,1) sleep(sleep_time) pfio.digital_write(7,0) sleep(sleep_time) pfio.digital_write(5,1) sleep(sleep_time) pfio.digital_write(4,0) sleep(sleep_time) pfio.digital_write(6,1) sleep(sleep_time) pfio.digital_write(5,0) sleep(sleep_time); pfio.digital_write(7,1); sleep(sleep_time) pfio.digital_write(6,0) sleep(sleep_time) pfio.digital_write(7,0) def clockwise(rotations, speed) sleep_time=0.1 / float(speed) for loop in range(1,int(512*float(rotations))) pfio.digital_write(7,1) sleep(sleep_time) pfio.digital_write(4,0) sleep(sleep_time) pfio.digital_write(6,1) sleep(sleep_time) pfio.digital_write(7,0) sleep(sleep_time) pfio.digital_write(5,1) sleep(sleep_time) pfio.digital_write(6,0) sleep(sleep_time) pfio.digital_write(4,1) sleep(sleep_time) pfio.digital_write(5,0) sleep(sleep_time) pfio.digital_write(4,0)
Step 7:
Done!
The motor I used was 28BYJ48 5V DC
Your motor should now obey orders you type!
(make your speed 10-600)
If you have any problems, ask me!
The motor I used was 28BYJ48 5V DC
Your motor should now obey orders you type!
(make your speed 10-600)
If you have any problems, ask me!
No comments:
Post a Comment