arduino驱动步进电机附代码#define DIR 3 //⽅向信号
#define PUL 4 //脉冲信号
int num;
String shuju;
int mark;
void tup(){
// put your tup code here, to run once:
办婚宴酒席pinMode(DIR, OUTPUT);
pinMode(PUL, OUTPUT);
十二本纪Serial.begin(9600);
digitalWrite(DIR, LOW);//设置步进电机转动⽅向
幽默祝福语
}
乐谱入门
void loop(){
if(Serial.available()>0)
{
shuju +=ad());
delay(2);
mark =1;
}
if(mark==1){
// Serial.println(shuju);
Int();
if(num==1){turn(200); Serial.println(num);}绿色痰是什么原因
if(num==2){turn(400); Serial.println(num);}
if(num==3){turn(600); Serial.println(num);}
if(num==4){turn(800); Serial.println(num);}三年级优秀日记
if(num==5){digitalWrite(DIR, LOW);Serial.println(num);}
if(num==6){digitalWrite(DIR,1);Serial.println(num);}
mark =0;
shuju="";
}
}
void turn(int count)
{伦琴
for(int i =0; i < count; i++)
{
digitalWrite(PUL, HIGH);
五年级上册的作文delayMicroconds(800);
digitalWrite(PUL, LOW);
delayMicroconds(800);
}
}
接线⾃⼰去⽹上找 很多(这不就是⽹上吗。。。。。主要是我懒)
然后发送1 2 3 4 5 6 3421 就可以看到效果了