用2262/2272红外遥控模块,接收到信号 引脚置高电平控制舵机转向arduino板子是nano
遥控模块输入接口A=D0接nano D5,输出接口B=D1接D7
舵机输出信号接D9
我编写代码后 按A,舵机转90度后,回自动回零!怎么使它保持,让我按B的时候令他回0
自己编写的代码,纯小白,希望大家指点
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
// incoming serial byte
int pos = 0; // variable to store the servo position
void setup() {
// put your setup code here, to run once:
c; // attaches the servo on pin 9 to the servo object
pinMode(5,INPUT);
pinMode(7,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
myservo.attach(9);
if(digitalRead(5)==HIGH){
myservo.write(90);
}
else if(digitalRead(7)==HIGH){
myservo.write(0);
}
delay(1000);
}
遥控模块输入接口A=D0接nano D5,输出接口B=D1接D7
舵机输出信号接D9
我编写代码后 按A,舵机转90度后,回自动回零!怎么使它保持,让我按B的时候令他回0
自己编写的代码,纯小白,希望大家指点
#include <Servo.h>
Servo myservo; // create servo object to control a servo
// a maximum of eight servo objects can be created
// incoming serial byte
int pos = 0; // variable to store the servo position
void setup() {
// put your setup code here, to run once:
c; // attaches the servo on pin 9 to the servo object
pinMode(5,INPUT);
pinMode(7,INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
myservo.attach(9);
if(digitalRead(5)==HIGH){
myservo.write(90);
}
else if(digitalRead(7)==HIGH){
myservo.write(0);
}
delay(1000);
}