查看“Control stepper motor”的源代码
←
Control stepper motor
跳转至:
导航
、
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{| style="width: 800px;" |- | ==Objective== The course will show you how to control stepper motor via “Processing”. ==Equipment== *'''[[Microduino-Core]]''' *'''[[Microduino-FT232R]]''' '''[[Microduino-A4982]]''' *Other Hardware Equipment **A USB cable **A pegboard **A copper cylinder and a screw *Welding tools **Electric iron **Tin solder **Wire **Tweezer ==Schematic== [[File:Stepper_motor.jpg|600px|center|thumb]] ==Program== https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Processing/MicroduinoStepperControl https://github.com/Microduino/Microduino_Tutorials/tree/master/Microduino_Processing/ProcessingStepperControl ==Debugging== The hardware buildup is similar to that of the DC motor in the 38th advanced course: http://www.microduino.cc/wiki/index.php?title=%E7%AC%AC%E4%B8%89%E5%8D%81%E5%85%AB%E8%AF%BE--Microduino_%E6%AD%A5%E8%BF%9B%E7%94%B5%E6%9C%BA%E9%A9%B1%E5%8A%A8/zh *Step 1:Cut pegboard with the right size; *Step 2:Make sure a right base location and weld the circuit according to the schematic; [[File:A4982.png|thumb|600px|center|洞洞板焊法]] [[File:A4982_Stepper_motor-t.jpg|thumb|600px|center|正面]] [[File:A4982_Stepper_motor-b.jpg|thumb|600px|center|反面]] *Building the circuit [[File:A4982_Stepper_motor-ok.jpg|thumb|600px|center|ok]] Step 3:Here is the code needed: The code of the two ends (Processing and Microduino) Microduino: //Read serial data void loop() { if(Serial.available()) { command=Serial.read(); Serial.println(command); if(command=='l') {//The stepper motor turns left if the data sent from Processing is 'l' stepper.setSpeed(motorSpeed); stepper.runSpeed(); } else if(command=='r') {//The stepper motor turns right if the data sent from Processing is 'r' stepper.setSpeed(-motorSpeed); stepper.runSpeed(); } else { stepper.stop();//otherwise, it will stop turning } } } Processing: //Monitor the mouse during drawing function. void draw() { background(0); image(img,0,0); noFill(); if("left".equals(turning)) { rect(30,80,150,210); fill(0); //Specify font color text ( "turn left" ,250,20); port.write("l"); }else if("right".equals(turning)) { rect(320,90,150,200); fill(0); //Specify font color text ( "turn right" ,250,20); port.write("r"); } } //Move the mouse and judge if it it inside the selection area // When the mouse is moved, the state of the turning is toggled. void mouseMoved() { if (mouseX > 30 && mouseX < 180 && mouseY > 80 && mouseY < 290) { turning = "left"; cursor(HAND); } else if (mouseX > 320 && mouseX < 470 && mouseY > 90 && mouseY < 290) { turning = "right"; cursor(HAND); } else { turning = "turning"; cursor(ARROW); } } Step 4:Download the code and pass the compiling. Step 5:Put the mouse on the “boy in the left” and the “girl in the right” to see the response of the stepper motor after the system goes well. ==Result== When putting the mouse on the “boy on the left”: [[File:processingStepperControlResult1.jpg|600px|center|thumb]] When putting the mouse on the “girl on the right”: [[File:processingStepperControlResult2.jpg|600px|center|thumb]] The stepper motor will turn in the appropriate direction ==Video== |}
返回至
Control stepper motor
。
导航菜单
个人工具
创建账户
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
Welcome
首页
创客大赛
大赛详情
3D打印
安装月球车
图形化编程
操控月球车
升级月球车
编程工具下载
软件下载
Arduino
Processing
Mixly
Scratch
模块套件
Microduino 102
mCookie 102
mCookie 202
mCookie 302
IBC
其他
应用套件
四轴飞行器
平衡车
小车CUBE
音乐播放器
刷卡音乐播放器
wifi气象站
彩虹音乐触摸灯
分贝检测仪
迎门汇报
LED点阵时钟
LED点阵屏幕
硬件
mCookie
Sensor
Microduino
MicroWrt
MicroNux
MicroRobot-Core
MicroRobot-CoreESP
ideaBoard
ideaBox
MicroMV
MicroAI
帮助
常见问题
帮助
工具
链入页面
相关更改
特殊页面
页面信息