单片机控制无刷电机(详细程序)——arduino源代码.doc

上传人:M****1 文档编号:556341321 上传时间:2024-01-05 格式:DOC 页数:3 大小:66KB
返回 下载 相关 举报
单片机控制无刷电机(详细程序)——arduino源代码.doc_第1页
第1页 / 共3页
单片机控制无刷电机(详细程序)——arduino源代码.doc_第2页
第2页 / 共3页
单片机控制无刷电机(详细程序)——arduino源代码.doc_第3页
第3页 / 共3页
亲,该文档总共3页,全部预览完了,如果喜欢就下载吧!
资源描述

《单片机控制无刷电机(详细程序)——arduino源代码.doc》由会员分享,可在线阅读,更多相关《单片机控制无刷电机(详细程序)——arduino源代码.doc(3页珍藏版)》请在金锄头文库上搜索。

1、最近对arduino很感兴趣,因为它的开源,编写简单,用它来控制无刷电机。通过调节电位器来控制无刷电机的转速。程序是根据arduino中自带的Servo库改编而成!当然也是需要根据电调的通信协议PPM。电调PPM如图:#include Servo myservo; / create servo object to control a servo int potpin = 0; / analog pin used to connect the potentiometerint val; / variable to read the value from the analog pin boolea

2、n a = true; iiivoid setup() myservo.attach(9,1000,2000); / attaches the servo on pin 9 to the servo object void loop() if(a) delay(2500); myservo.writeMicroseconds(1000); delay(2000); a=false; val = analogRead(potpin); / reads the value of the potentiometer (value between 0 and 1023) val = map(val, 0, 1023, 0, 179); / scale it to use it with the servo (value between 0 and 180) myservo.write(val); / sets the servo position according to the scaled value delay(15); / waits for the servo to get there

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 生活休闲 > 社会民生

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号