#include <LCD5110_Basic.h>
#include <Servo.h>
#define echo 5
#define trig 6
Servo cetvel;
LCD5110 ekran (8,9,10,11,12);
extern uint8_t SmallFont[];
extern uint8_t MediumNumbers[];
extern uint8_t BigNumbers[];
String firstRow = "Elektronik";
String secondRow = "Cetvel";
char filler = '0';
int mesafe = 0;
int sure = 0;
void setup() {
cetvel.attach(7);
pinMode(A0,INPUT);
Serial.begin(9600);
pinMode(trig,OUTPUT);
pinMode(echo,INPUT);
ekran.InitLCD();
ekran.setFont(SmallFont);
ekran.clrScr();
ekran.print(firstRow,18,0);
ekran.print(secondRow,30,8);
ekran.setFont(BigNumbers);
}
void loop() {
int x =analogRead(A0);
int yenideger=map(x,0,1023,0,180);
cetvel.write(yenideger);
digitalWrite(trig,LOW);
delayMicroseconds(5);
digitalWrite(trig,HIGH);
delayMicroseconds(10);
digitalWrite(trig,LOW);
sure = pulseIn(echo,HIGH,11600);
mesafe= sure*0.0345/2;
Serial.println(mesafe);
ekran.clrRow(3);
ekran.clrRow(4);
ekran.clrRow(5);
ekran.printNumI(mesafe,70,3,filler);
delay(500);
}