How to read an Analog Input

How to read an Analog Input

You can read the data of an Analog Input through:

...
int myAnalog;
...
void setup() {}

void loop() {
   myAnalog = analogRead(A0);
}

With this piece of code you’ll read the voltage of a sensor. As our analog input works between 0-10V, the read value (myAnalog) will be a value between 0-1023.

If the value of sensor is (3V), myAnalog value is 3*1023/10 = 307.

Comments are closed.