//================= Example7_3 ====================
#include <ESP32Servo.h>
Servo myservo;
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SH110X.h>
#define i2c_Address 0x3c
#define SCREEN_WIDTH 128
#define SCREEN_HEIGHT 64
#define OLED_RESET -1
Adafruit_SH1106G display = Adafruit_SH1106G(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);
#define analogPin 34
#define TRIGGER 32
#define ECHO 33
long distance;
void setup() {
  initOled();
  myservo.attach(18);

  functionsForPrintingAmessage(38, 5, "RADAR");
  display.setTextSize(1);
  functionsForPrintingAmessage(25, 35, "Distance = ");
  functionsForPrintingAmessage(30, 55, " Angle = ");
  pinMode(TRIGGER, OUTPUT);
  pinMode(ECHO, INPUT_PULLUP);
  digitalWrite(TRIGGER, LOW);
}
void loop() {
  for (int servoPosition = 0; servoPosition <= 180; servoPosition += 1) {
    distance = readDistanceUS();
    functionsForPrintingData(90, 35, distance);
    myservo.write(servoPosition);
    functionsForPrintingData(85, 55, servoPosition);
    delay(15);
  }
  for (int servoPosition = 0; servoPosition <= 180; servoPosition += 1) {
    distance = readDistanceUS();
    functionsForPrintingData(90, 35, distance);
    myservo.write(servoPosition);
    functionsForPrintingData(85, 55, servoPosition);
    delay(15);
  }
}
//==================================================
