Commit 89be2877 authored by Arlo's avatar Arlo
Browse files

Add new file

parents
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment