欧美极品高清xxxxhd,国产日产欧美最新,无码AV国产东京热AV无码,国产精品人与动性XXX,国产传媒亚洲综合一区二区,四库影院永久国产精品,毛片免费免费高清视频,福利所导航夜趣136
標題:
arduino控制單舵機(180度)2連續運動
[打印本頁]
作者:
阿斯頓馬丁奇諾
時間:
2018-4-21 08:28
標題:
arduino控制單舵機(180度)2連續運動
金工實習 控制小車
單片機源程序如下:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(0, 1); // RX, TX
#include <Servo.h>
Servo myservo; // create servo object to control a servo
int pos=60;
int p1=2; // variable to store the servo position
char val='/';
void setup()
{
Serial.begin(9600);
myservo.attach(p1); // attaches the servo on pin 2 to the servo object
myservo.write(pos); //初始化所有舵機位置,防止通電抖動。
delay(1000);
myservo.detach();
}
void loop() // run over and over
{
val=Serial.read();
if(val=='1')
{
myservo.attach(p1); // attaches the servo on pin 2 to the servo object
for(inti=1;i<=30;i++) // goes from 60 degrees to 30 degrees
{
pos--;
myservo.write(pos); // tell servo to go to position in variable 'pos'
delay(15); // waits 15ms for the servo to reach the position
}
If(pos==0)pos=180;
myservo.detach();
val='11';
}
if(val=='2')
{
myservo.attach(p1);
for(pos=30;pos<=60;pos+= 1) // goes from 30 degrees to 60 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
}
myservo.detach();
val='22';
}
}
復制代碼
所有資料51hei提供下載:
遙控單舵機(180度)2連續運動20171227.docx
(16.04 KB, 下載次數: 6)
2018-4-21 08:26 上傳
點擊文件名下載附件
下載積分: 黑幣 -5
歡迎光臨 (http://m.raoushi.com/bbs/)
Powered by Discuz! X3.1