Created
July 14, 2018 08:45
-
-
Save elktros/b63002a8d084aef75ff8e959c8397578 to your computer and use it in GitHub Desktop.
Code for interfacing Voltage Sensor with Arduino for measuring voltages less than or equal to 25V.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "LiquidCrystal.h" | |
const int voltageSensor = A0; | |
float vOUT = 0.0; | |
float vIN = 0.0; | |
float R1 = 30000.0; | |
float R2 = 7500.0; | |
int value = 0; | |
LiquidCrystal lcd(7, 6, 5, 4, 3, 2); // RS, E, D4, D5, D6, D7 | |
void setup() | |
{ | |
//Serial.begin(9600); | |
lcd.begin(16,2); | |
lcd.print(" Measure > 25V "); | |
delay(2000); | |
} | |
void loop() | |
{ | |
value = analogRead(voltageSensor); | |
vOUT = (value * 5.0) / 1024.0; | |
vIN = vOUT / (R2/(R1+R2)); | |
//Serial.print("Input = "); | |
//Serial.println(vIN); | |
lcd.setCursor(0,0); | |
lcd.print("Input = "); | |
lcd.setCursor(9,0); | |
lcd.print(vIN); | |
delay(500); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, very good information. Before this, i did a conection with a burning ground wire results. Per your diagram, i think my mistake was the + male terminal conection to the +5 Vcc of the Arduino uno R3, when It should be NC.