查看“The Use of Servo”的源代码
←
The Use of Servo
跳转至:
导航
、
搜索
因为以下原因,您没有权限编辑本页:
您所请求的操作仅限于该用户组的用户使用:
用户
您可以查看与复制此页面的源代码。
{| style="width: 800px;" |- | ==Purpose== This tutorial shows you the way to use servo under mCookie. ==Equipment== *'''[[Microduino-CoreUSB]]''' *'''[[Microduino-Servo]]''' *'''[[Microduino-Sensorhub]]''' *Other Hardwar Equipment **USB cable One ==Program== #include <Servo.h> Servo myservo; // create servo object to control a servo // a maximum of eight servo objects can be created int pos = 0; // variable to store the servo position void setup() { myservo.attach(9); // attaches the servo on pin 9 to the servo object } void loop() { for(pos = 0; pos < 180; pos += 1) // goes from 0 degrees to 180 degrees { // in steps of 1 degree myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } for(pos = 180; pos>=1; pos-=1) // goes from 180 degrees to 0 degrees { myservo.write(pos); // tell servo to go to position in variable 'pos' delay(15); // waits 15ms for the servo to reach the position } } ==Debugging== Step 1: Plug Microduino servo to D9 pin of Microduino-Sensorhub. [[File:McookieServoSensor.png|600px|center|thumb]] Step 2: Connect USB cable to your PC, download the code and program it to Microduino-CoreUSB. [[File:McookieServoSensor1.png|600px|center|thumb]] Step 3: After programming, the servo will swing among the reading of 0 to 180. [[File:McookieServoSensor2.png|600px|center|thumb]] Step 4: Try to change the angle of swing repeatedly and see if it is accuracy. [[File:McookieServoSensor3.png|600px|center|thumb]] ==Result== You can control the servo and make it swing to a certain angle. ==Video== |}
返回至
The Use of Servo
。
导航菜单
个人工具
创建账户
登录
名字空间
页面
讨论
变种
视图
阅读
查看源代码
查看历史
更多
搜索
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
帮助
常见问题
帮助
工具
链入页面
相关更改
特殊页面
页面信息