Nothing too fancy this time around, just a simple project that calculates the resistance of a resistor. The circuit is based on a simple voltage divider. First, a wire is connected from the 5V pin on the Arduino to the breadboard +5V bus. Then, another wire connects the Gnd pin on the Arduino to the GND bus on the breadboard. Now that you have power, put two resistors in series. One should be your “known” resistance; I used a 10 kohm resistor for this. The other is the “unknown” resistor that we are trying to find the resistance of. In between these two resistors, another wire should be connected to one of the analogue pins on the Arduino (I used pin 0). Below are two pictures which show the setup.

Here is the Arduino code which calculates the unknown resistance, and outputs it to serial:
int aPinIn = 0; // Analogue Input on Arduino int val = 0; // The raw analogue value float Vout = 0.0; // Voltage at point between resistors // (relative to ground) float Vin = 5.0; // Vcc (5 Volts) float Rknown = 10000.0; // The known resistor (10 kohms) float Runknown = 0.0; void setup(){ Serial.begin(9600); digitalWrite(13, HIGH); } void loop(){ val = analogRead(aPinIn); // Read in val (0-1023) Vout = (Vin/1024.0) * float(val); // Convert to voltage Runknown = Rknown*((Vin/Vout) - 1); // Calculate Runknown Serial.print("Vout: "); Serial.println(Vout); // Output everything Serial.print("R: "); Serial.println(Runknown); delay(1000); // delay for readability }
Here is the serial output (updating every second):

Not bad. According to the color code, the unknown is a 330 Ohm resistor with 5% tolerance. The circuit/code produces a value of 333.