Voltage_Sensor.ino
1 #define VOLTAGE_PIN 14 2 #define REF_VOLTAGE 3.3 3 #define ADC_RESOLUTION 4095 4 5 6 void setup() { 7 Serial.begin(115200); 8 pinMode(VOLTAGE_PIN, INPUT); 9 } 10 11 void loop() { 12 int adcVal = analogRead(VOLTAGE_PIN); 13 float voltage = (adcVal/(float)ADC_RESOLUTION) * REF_VOLTAGE; 14 Serial.print("Voltage: "); 15 Serial.println(voltage); 16 Serial.println(); 17 delay(1000); 18 }