Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Green Science
solar-heart
Commits
89be2877
Commit
89be2877
authored
Jan 24, 2020
by
Arlo
Browse files
Add new file
parents
Changes
1
Hide whitespace changes
Inline
Side-by-side
arduino voltmeter
0 → 100644
View file @
89be2877
int analogInput = 1;
float Vout = 0.00;
float Vin = 0.00;
float I = 0.00;
float R1 = 98000.00; // resistance of R1 (100K)
float R2 = 9880.00; // resistance of R2 (10K)
int val = 0;
void setup(){
pinMode(analogInput, INPUT); //assigning the input port
Serial.begin(9600); //BaudRate
}
void loop(){
val = analogRead(analogInput);//reads the analog input
Vout = (val * 5.11) / 1024.00; // formula for calculating voltage out i.e. V+, here 5.00
Vin = Vout / (R2/(R1+R2)); // formula for calculating voltage in i.e. GND
I = Vin/(R2/(R1+R2));
//if (Vin<0.09)//condition
{
//Vin=0.00;//statement to quash undesired reading !
}
Serial.print("\t V = ");
Serial.print(Vin);
Serial.print("\t I = ");
Serial.print(I);
delay(2000); //for maintaining the speed of the output in serial moniter
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment