Voltage with analog input
int sensorValue = 0;
void setup()
{
pinMode(A0, INPUT);
pinMode(13, OUTPUT);
Serial.begin(9600);
int res=0.0049;
}
void loop()
{
// read the value from the sensor
sensorValue = analogRead(A0); //0-1023
float volt=map(sensorValue,0,1023,0000,5000);
Serial.print("Voltage =");
Serial.println(volt/1000);
Serial.print("=");
Serial.println(sensorValue);
digitalWrite(13, HIGH);
delay(sensorValue); // Wait for sensorValue millisecond(s)
digitalWrite(13, LOW);
//Serial.println(sensorValue*res);
delay(sensorValue); // Wait for sensorValue millisecond(s)
}
voltage>5 vlot
Comments
Post a Comment