/* 03/09/2021 analogReadv2ConvertToVoltage Convert the analogRead value into a voltage DO NOT EXCEED THE VOLTAGE INPUT LIMITS FOR YOUR BOARD Maximum Voltage Arduino UNO/nano/Mega 2560 5v DC Maximum Voltage Arduino Due 3.3v DC Previous lessons used in this sketch: lesson 2 "Hello World" Basics of printing to Serial Window http://www.digitaltown.co.uk/lesson2helloworld.php Lesson 6 boolean, byte, int, long, unsigned int, unsigned long http://www.digitaltown.co.uk/lesson6bitsandbytes.php Lesson 8 Mathematics Example 4 for information on Float variable http://www.digitaltown.co.uk/lesson8mathematics.php */ //Variables int readPin; //The variable that will store the returned value from the analog pin float myVoltage; //variable that will store the volatage //A const int with the pin number const int analogPin = A5; void setup() { Serial.begin(9600); Serial.println("analogReadv2ConvertToVoltage..."); Serial.println(" "); } void loop() { readPin = analogRead(analogPin); Serial.print("readPin value: "); Serial.println(readPin); //Convert to voltage, voltage is 0.0049 volts per step on 5.0v boards myVoltage = readPin * 0.0049; Serial.print("myVoltage volts: "); Serial.println(myVoltage); delay(300); }