Open crane-may opened 10 years ago
#include <Stepper.h>
#define STEPS 100
Stepper stepper(STEPS, 41, 42, 43, 44);
void setup(){
stepper.setSpeed(200);
}
void loop(){
stepper.step(80);
}
#include <Stepper.h>
#define STEPS 96
Stepper stepper(STEPS, 41, 42, 43, 44);
void setup(){
// pinMode(41, OUTPUT);
// pinMode(42, OUTPUT);
// pinMode(43, OUTPUT);
// pinMode(44, OUTPUT);
pinMode(45, OUTPUT);
pinMode(46, OUTPUT);
digitalWrite(45, HIGH);
digitalWrite(46, HIGH);
stepper.setSpeed(120);
}
void loop(){
// digitalWrite(41, HIGH);
// digitalWrite(42, LOW);
// digitalWrite(43, HIGH);
// digitalWrite(44, LOW);
stepper.step(10);
}
int step1 = 33;
int dir1 = 35;
int step2 = 51;
int dir2 = 53;
void setup() {
for(int i=23;i<=53;i+=2){
pinMode(i, OUTPUT);
}
digitalWrite(23, LOW);
digitalWrite(25, LOW);
digitalWrite(27, LOW);
digitalWrite(29, HIGH);
digitalWrite(31, HIGH);
digitalWrite(39, LOW);
digitalWrite(41, LOW);
digitalWrite(43, LOW);
digitalWrite(45, LOW);
digitalWrite(47, HIGH);
digitalWrite(49, HIGH);
}
void step(boolean dir,int steps){
digitalWrite(dir1,dir);
digitalWrite(dir2,dir);
delay(50);
for(int i=0;i<steps;i++){
digitalWrite(step1, HIGH);
digitalWrite(step2, HIGH);
delayMicroseconds(800);
digitalWrite(step1, LOW);
digitalWrite(step2, LOW);
delayMicroseconds(3000);
}
}
void loop(){
step(true,1600);
delay(500);
step(false,1600);
delay(500);
}
28BYJ-48 有点慢,目测6s转一周