Arduino红外遥控舵机
2019/09
01
13:09
#include "IRremote.h"
#include <Servo.h>
int RECV_PIN = 11;
int SERVO_PIN = 9;
Servo myservo;
IRrecv irrecv(RECV_PIN);
decode_results results;
void setup() {
pinMode(RECV_PIN, INPUT);
Serial.begin(9600);
irrecv.enableIRIn();
myservo.attach(SERVO_PIN);
}
void loop() {
if (irrecv.decode(&results))
{
Serial.println(results.value);
int angle = results.value % 180;
myservo.write(angle);
delay(100);
irrecv.resume();
}
}
VOUT接11号口
CopyRights: The Post by BY-NC-SA For Authorization,Original If Not Noted,Reprint Please Indicate From 老刘@开发笔记
Post Link: Arduino红外遥控舵机
Post Link: Arduino红外遥控舵机