You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
int pin=3;//表示信号针脚的地址
int speed=100;
while(true){//确保一个loop需要使用0.02秒运行一次
digitalWrite(pin,HIGH);//高电平
usleep(500+speed);//高电平存在时间越长加速率越高
digitalWrite(pin,LOW);//低电平
usleep(20000-500-speed);//填充延时时间
}
SG90陀机角度
int pin = 7;
int angle = 80;//角度:0~180度.PS: SG90陀机的旋转角度只有180度
digitalWrite(pin ,HIGH);//高电平
usleep(angle*11+500);//将角度转化为500-2480的脉宽值,__SG90陀机的控制范围为500-2480
digitalWrite(pin ,LOW); //低电平
usleep(20000-500-angle*11); //填充延时时间
Activity
keyskull commentedon Feb 5, 2016
example for Arduino的电平转换函数