top of page

Discover Learn Arduino

Search

Arduino Ohm-meter

  • jpatel
  • Jan 24, 2019
  • 1 min read


CODE:


int analogPin= 0;

int raw= 0;

int Vin= 5;

float Vout= 0;

float R1= 1000;

float R2= 0;

float buffer= 0;


void setup()

{

Serial.begin(9600);

}


void loop()

{

raw= analogRead(analogPin);

if(raw)

{

buffer= raw * Vin;

Vout= (buffer)/1024.0;

buffer= (Vin/Vout) -1;

R2= R1 * buffer;

Serial.print("Vout: ");

Serial.println(Vout);

Serial.print("R2: ");

Serial.println(R2);

delay(1000);

}

}


 

Enter the value of your known resistor (in Ohms) on line 5 of the code above. In my case, I’m using a known resistor with a value of 1K Ohms (1000 Ohms). Therefore, my line 5 should look like this: float R1 = 1000;.

The program sets up analog pin A0 to read the voltage between the known resistor and the unknown resistor. You can use any other analog pin though, just change the pin number in line 1, and wire the circuit accordingly.

When you open up the serial monitor you’ll see the resistance values printed once per second. There will be two values, R2 and Vout.

R2: is the resistance of your unknown resistor in Ohms. Vout: is the voltage drop across your unknown resistor. Here i had used 2.2k ohm resistor. the serial monitor value is shown below.


 




 
 
 

Comments


Home: Blog2

Subscribe

Home: GetSubscribers_Widget

Contact

Your details were sent successfully!

Components Inside of Mobile Phone
Home: Contact

©2018 by Learn Arduino. Proudly created with Wix.com

bottom of page