arduino servo的用法
来源:互联网 发布:企业短信群发软件 编辑:程序博客网 时间:2024/06/11 07:26
1.servo类成员函数
函数
说明
attach()
设定舵机的接口,只有9或10接口可利用。
write()
用于设定舵机旋转角度的语句,可设定的角度范围是0°到180°。
writeMicroseconds()
用于设定舵机旋转角度的语句,直接用微秒作为参数。
read()
用于读取舵机角度的语句,可理解为读取最后一条write()命令中的值。
attached()
判断舵机参数是否已发送到舵机所在接口。
detach()
使舵机与其接口分离,该接口(9或10)可继续被用作PWM接口。
2.Arduino舵机实现代码
// Sweep// by BARRAGAN <http://barraganstudio.com> // This example code is in the public domain.#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 } }
0 0
- arduino servo的用法
- arduino: 各种Arduino基础器件的用法图
- 【arduino】利用servo库和一个摇杆控制两个小舵机
- Arduino串口的一些高级用法
- Arduino 串口的一些高级用法
- 串口的一些高级用法arduino
- 关于Servo项目中Rust代码行数的数据来源
- Arduino串口高级用法
- arduino之pwm用法
- arduino 引脚用法
- Visual Servo菜鸟
- 基于Arduino实现Arduino控制的电灯
- 【Arduino】基于arduino的激光坦克
- 控制Arduino的利器-Windows Remote Arduino
- 控制Arduino的利器-Windows Remote Arduino
- Arduino 的函数库
- Arduino串口的使用
- Arduino的数据类型
- 获取html节点时过滤空白节点
- FFMPEG 批量连接视频文件示范代码
- 海量路由表可以使用HASH表存储吗-HASH查找和TRIE树查找
- Hibernate入门教程
- 牛顿迭代法应用——求数的平方根和立方根
- arduino servo的用法
- java对图片的转码和解码 实用
- ffmpeg截取一段视频中一段视频
- 剑指offer--面试题27:二叉搜索树与双向链表--Java实现
- 实现类似Tumblr的Title Bar跟随滑动渐变的效果
- Android在全屏状态下键盘覆盖输入框问题
- 动态规划--凸多边形最优三角剖分
- Android的canvas.rotate()与canvas.translate研究
- Unity3D跑酷游戏开发-无尽的道路