手持脱机步进电机控制器@青年创造工坊
手持脱机步进电机控制器简介:
不知道各位小伙伴们常不常用步进电机,因其精确的控制性很容易实现步进电机的角度和速度控制,然而也因为此特性导致在前期对步进电机调试时比较繁琐;所以结合arduino nano和A4988,我们开源一款方便测试步进电机,同时又可烧写不同程序实现移植复用的手持脱机步进电机控制器。
材料:
品名单价数量合计
arduino nano12112
A4988步进电机驱动板2.912.9
3.5mmDC插座0.810.8
排插7pin0.0940.36
排插8pin0.1220.24
排插4pin0.0810.08
XH2.54,4pin弯针0.0410.04
导线0.1181.8
洞洞板,3x7cm2.512.5
接线图:
烧录代码:int Msteppin=7;
int Mdirpin=6;
int Menpin=8;
int i=200;
int BUTTON1 = A2;
int BUTTON2 = A3;
char key;
void setup()
{
pinMode(Msteppin,OUTPUT);//驱动
pinMode(Mdirpin,OUTPUT);//方向
pinMode(Menpin,OUTPUT);//使能
digitalWrite(Menpin,LOW);
pinMode(A2,INPUT_PULLUP);//A2上拉
pinMode(A3,INPUT_PULLUP);//A3上拉
Serial.begin(9600);
}
void a()
{digitalWrite(Mdirpin,HIGH);
int i=0;
while(i<200)
{digitalWrite(Msteppin,HIGH);
delayMicroseconds(800);
digitalWrite(Msteppin,LOW);
delayMicroseconds(800);
i++;}
}
void b()
{
digitalWrite(Mdirpin,LOW);
int i=0;
while(i<200)
{digitalWrite(Msteppin,HIGH);
delayMicroseconds(800);
digitalWrite(Msteppin,LOW);
delayMicroseconds(800);
i++;}
}
void loop()
{
while (digitalRead(BUTTON2) == LOW)
{ a();Serial.println('0'); }
while (digitalRead(BUTTON1) == LOW)
{ b();Serial.println('c'); }
int key=Serial.read();
switch(key)
{ case'0':a();delay(10);break;
case'c':b();delay(10);break;
case't':a();delay(1000);b();delay(1000);break;
default:break;
}
}
实物展示:
视频地址:
https://v.youku.com/v_show/id_XNDEzMTM2NDc3Mg==.html
3d打印外壳下载地址:
http://www.dayin.la/user/23742
不错,谢谢分享
页:
[1]