#include <Servo.h>
const int rdpin =15;
int rdval=0;
float volt =0.0;
static const int servoPin = 13;
Servo servo1;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(rdpin, INPUT);
servo1.attach(
servoPin,
Servo::CHANNEL_NOT_ATTACHED,
0,
180
);
servo1.write(0);
}
void loop() {
rdval=analogRead(rdpin);
volt=rdval*(180.0/4095);
Serial.print("readvalue = ");
Serial.println(rdval);
Serial.print("Volt = ");
Serial.print(volt);
Serial.println(" Volt");
servo1.write(volt);
delay(100);
}