#include <Servo.h>
Servo servomotor;
int prevTeplota = 0;
String vstup = "";
void setup() {
Serial.begin(9600);
servomotor.attach(3);
servomotor.write(90);
}
void loop() {
int hodnota = analogRead(A0);
int teplota = map(hodnota, 0, 1023, 0, 50);
if ( prevTeplota != teplota)
{
prevTeplota = teplota;
Serial.println("Nastavil si teplotu: " + String(teplota));
}
vstup = Serial.readString();
vstup.trim();
if (vstup == "right")
{
servomotor.write(180);
}
if (vstup == "left")
{
servomotor.write(0);
}
if (vstup == "center")
{
servomotor.write(90);
}
}