28 lines
593 B
C++
28 lines
593 B
C++
#include <Servo.h>
|
|
|
|
Servo myservo;
|
|
int num;
|
|
|
|
void setup() {
|
|
// put your setup code here, to run once:
|
|
pinMode(2, INPUT); // объявляем пин 2 как вход
|
|
pinMode(3, INPUT); // объявляем пин 2 как вход
|
|
myservo.attach(9);
|
|
}
|
|
|
|
void loop() {
|
|
// put your main code here, to run repeatedly:
|
|
if (digitalRead(2) == HIGH) // когда на пин 2 поступает высокий сигнал
|
|
{
|
|
num=num+10;
|
|
myservo.write(num);
|
|
delay(100);
|
|
}
|
|
if (digitalRead(3) == HIGH)
|
|
{
|
|
num=num-10;
|
|
myservo.write(num);
|
|
delay(100);
|
|
}
|
|
}
|