#include <ESP32Servo.h>
Servo myservo;
int pos = 0;
int redLedPin = 2;
int greenLedPin = 4;
void setup() {
Serial.begin(9600);
myservo.attach(15);
pinMode(redLedPin, OUTPUT);
pinMode(greenLedPin, OUTPUT);
}
void loop() {
for (pos = 45; pos <= 180; pos += 45) {
myservo.write(pos);
delay(500);
if (pos >= 35 && pos <= 60) {
digitalWrite(redLedPin, HIGH);
digitalWrite(greenLedPin, LOW);
} else if (pos >= 70 && pos <= 90) {
digitalWrite(greenLedPin, HIGH);
digitalWrite(redLedPin, LOW);
Serial.print("Servo повернут на ");
Serial.print(pos);
Serial.println(" градусов.");
} else {
digitalWrite(redLedPin, LOW);
digitalWrite(greenLedPin, LOW);
}
}
}
esp:VIN
esp:GND.2
esp:D13
esp:D12
esp:D14
esp:D27
esp:D26
esp:D25
esp:D33
esp:D32
esp:D35
esp:D34
esp:VN
esp:VP
esp:EN
esp:3V3
esp:GND.1
esp:D15
esp:D2
esp:D4
esp:RX2
esp:TX2
esp:D5
esp:D18
esp:D19
esp:D21
esp:RX0
esp:TX0
esp:D22
esp:D23
led1:A
led1:C
led2:A
led2:C
r1:1
r1:2
r2:1
r2:2
servo1:GND
servo1:V+
servo1:PWM