   # Measuring Resistance with Microcontrollers

This app was made to show how a resistor can be measured.

An ohmmeter works similarly to a voltmeter. That is, it is based on the division of voltage.

We have our app on our youtube channel. If you wish, you can also watch the related video.

Thanks to the voltage divider circuit connected to the analog input of the microcontroller, we get an analog input voltage. Together with a 100K resistor (R1), the resistor (RX) to be measured divides the input voltage. Our reference resistor is the 100K resistor R1.

With the help of the code on the Arduino code screen, we find the value of RX as follows:

`RX=(volt_in*R1)/(5-volt_in);`

The “volt_in” here is the voltage taken from the microcontroller terminal A0. Since the R1 resistance is 100K, we add it to the formula as 100000. We find the RX value in ohms. This value appears on the Arduino IDE code screen, on the "serial port" screen. If desired, this value can be transferred to an LCD display or 7 segment LED display connected to the microcontroller. An independent ohmmeter can be made.

Below are the microcontroller codes required for measurement:

void setup()
{  Serial.begin (9600);
}

void loop()
{
float volt_x = analogRead(A0);// Vin INPUT
float volt_in=5*(volt_x/1023);
float RX=(volt_in*100000)/(5-volt_in);  //------------>>>>>>  resistance formula
float RX_divided=RX/1000;    // ohm ----> K OHM

Serial.print(" Analog İnput: ");
Serial.println(volt_in);
Serial.print("RX Resistor Value: ");
Serial.print(RX);
Serial.print(" Ohm-----> ");
Serial.print(RX_divided);
Serial.print(" Kilo Ohm");
delay(1000);
}