Components and supplies
Jumper wires (generic)
Stepper motor 28BYJ-48
Breadboard (generic)
Arduino Nano R3
Project description
Code
Code for the Hour control
arduino
1/* 2 Stepper Motor Control - one step at a time 3 4 This program drives a unipolar or bipolar stepper motor. 5 The motor is attached to digital pins 8 - 11 of the Arduino. 6 7 The motor will step one step at a time, very slowly. You can use this to 8 test that you've got the four wires of your stepper wired to the correct 9 pins. If wired correctly, all steps should be in the same direction. 10 11 Use this also to count the number of steps per revolution of your motor, 12 if you don't know it. Then plug that number into the oneRevolution 13 example to see if you got it right. 14 15 Created 30 Nov. 2009 16 by Tom Igoe 17 18 */ 19 20#include <Stepper.h> 21 22const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution 23 // for your motor 24 25// initialize the stepper library on pins 8 through 11: 26Stepper myStepper(stepsPerRevolution, 8,9,10,11); 27 28int stepCount = 0; // number of steps the motor has taken 29 30void setup() { 31 // initialize the serial port: 32 Serial.begin(9600); 33} 34 35void loop() { 36 // step one step: 37 myStepper.step(1); 38 Serial.print("steps:" ); 39 Serial.println(stepCount); 40 stepCount++; 41 delay(21600); 42} 43
Code for the Hour control
arduino
1/* 2 Stepper Motor Control - one step at a time 3 4 This program drives a unipolar or bipolar stepper motor. 5 The motor is attached to digital pins 8 - 11 of the Arduino. 6 7 The motor will step one step at a time, very slowly. You can use this to 8 test that you've got the four wires of your stepper wired to the correct 9 pins. If wired correctly, all steps should be in the same direction. 10 11 Use this also to count the number of steps per revolution of your motor, 12 if you don't know it. Then plug that number into the oneRevolution 13 example to see if you got it right. 14 15 Created 30 Nov. 2009 16 by Tom Igoe 17 18 */ 19 20#include <Stepper.h> 21 22const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution 23 // for your motor 24 25// initialize the stepper library on pins 8 through 11: 26Stepper myStepper(stepsPerRevolution, 8,9,10,11); 27 28int stepCount = 0; // number of steps the motor has taken 29 30void setup() { 31 // initialize the serial port: 32 Serial.begin(9600); 33} 34 35void loop() { 36 // step one step: 37 myStepper.step(1); 38 Serial.print("steps:" ); 39 Serial.println(stepCount); 40 stepCount++; 41 delay(21600); 42} 43
Code for the Minute control
arduino
1/* 2 Stepper Motor Control - one step at a time 3 4 This program drives a unipolar or bipolar stepper motor. 5 The motor is attached to digital pins 8 - 11 of the Arduino. 6 7 The motor will step one step at a time, very slowly. You can use this to 8 test that you've got the four wires of your stepper wired to the correct 9 pins. If wired correctly, all steps should be in the same direction. 10 11 Use this also to count the number of steps per revolution of your motor, 12 if you don't know it. Then plug that number into the oneRevolution 13 example to see if you got it right. 14 15 Created 30 Nov. 2009 16 by Tom Igoe 17 18 */ 19 20#include <Stepper.h> 21 22const int stepsPerRevolution = 200; // change this to fit the number of steps per revolution 23 // for your motor 24 25// initialize the stepper library on pins 8 through 11: 26Stepper myStepper(stepsPerRevolution, 8,9,10,11); 27 28int stepCount = 0; // number of steps the motor has taken 29 30void setup() { 31 // initialize the serial port: 32 Serial.begin(9600); 33} 34 35void loop() { 36 // step one step: 37 myStepper.step(1); 38 Serial.print("steps:" ); 39 Serial.println(stepCount); 40 stepCount++; 41 delay(1800); 42} 43
Comments
Only logged in users can leave comments
garysat
0 Followers
•0 Projects
0