【Arduino】舵机操作
来源:互联网 发布:ios 仿今日头条 源码 编辑:程序博客网 时间:2024/05/01 19:36
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 } }
3.Arduino舵机连接图
实物图中,舵机GND(棕色线)、VCC(红色线)、Signal(橙色线)
线路图中,舵机GND(黑色线)、VCC(红色线)、Signal(黄色线)
0 0
- 【Arduino】舵机操作
- 【Arduino】开发入门【八】舵机操作+源代码
- 【Arduino】开发入门【八】舵机操作+源代码
- 【Arduino】开发入门【八】舵机操作+源代码
- 舵机arduino
- Arduino 摇杆控制 舵机
- arduino-摇杆控制舵机
- Arduino之舵机控制
- Arduino舵机控制1
- Arduino舵机控制
- Arduino—舵机控制
- arduino-控制舵机
- arduino-舵机控制(示例)
- 利用arduino 控制舵机转动
- Arduino 卡片11可控舵机
- Arduino对舵机的控制
- Arduino 舵机驱动板编程
- Arduino双舵机串口控制源代码
- Gvim插件
- 解决图片太大溢出问题、CSS 限制图片最大宽度、图片按比例自动缩放
- LeetCode(162) Find Peak Element
- inifile
- SDUT 3099 递归回溯?
- 【Arduino】舵机操作
- seam中另一种上传下载的实现思路
- C++/CLI 托管C++之导出注释【11】
- 友元函数与操作符重载入门+const修饰this指针
- vs2008svn插件
- Android NDK开发Crash错误定位
- ethtool 在 Linux 中的实现框架和应用
- 随机播放音效 在音频组件中添加好元素 Random.Range在自定义的函数中可以用整形
- 2014年个人总结