#include <ESP32Servo.h>
#include <Adafruit_ILI9341.h>
Servo servo1;
Servo servo2;
int servo1Pin = 22;
int servo2Pin = 21;
#define TFT_DC 27
#define TFT_CS 14
void setup() {
Serial.begin(115200); // Any baud rate should work
Serial.println("Hello Arduino\n");
// Display
Adafruit_ILI9341 tft = Adafruit_ILI9341(TFT_CS, TFT_DC);
tft.begin();
tft.setRotation(1);
tft.setCursor(26, 120);
tft.setTextColor(ILI9341_RED);
tft.setTextSize(3);
tft.println("Hello, TFT!");
// Allow allocation of all timers
ESP32PWM::allocateTimer(0);
ESP32PWM::allocateTimer(1);
ESP32PWM::allocateTimer(2);
ESP32PWM::allocateTimer(3);
pinMode(servo2Pin, OUTPUT);
servo1.setPeriodHertz(50); // standard 50 hz servo
servo1.attach(servo1Pin, 500, 2400);
delay(15);
servo2.setPeriodHertz(50); // standard 50 hz servo
servo2.attach(servo2Pin, 500, 2400);
// using default min/max of 1000us and 2000us
// different servos may require different min/max settings
// for an accurate 0 to 180 sweep
servo1.write(50);
servo2.write(30);
delay(3000);
servo1.write(90);
servo2.write(90);
}
void loop() {
}