How to use Ohm’s law calculator
- Enter the known values for any two of the three variables (voltage, current, or resistance) in the input fields.
- Leave the input field for the unknown variable empty.
- Click the “Calculate” button.
- The calculator will calculate the value of the unknown variable and fill it into the appropriate input field.
For example, let’s say we want to calculate the current flowing through a resistor that has a resistance of 100 ohms and a voltage of 12 volts. We would do the following:
- Enter 12 in the input field for voltage.
- Enter 100 in the input field for resistance.
- Leave the input field for current empty.
- Click the “Calculate” button.
- The calculator will calculate the value of the current to be 0.12 amps and fill it into the input field for current.
Explanation of Ohm’s law
Ohm’s Law states that the current flowing through a conductor between two points is directly proportional to the voltage across the two points, provided that the temperature and other physical conditions remain constant. This relationship is expressed mathematically as:
V = IR
Where:
V is the voltage across the conductor,
I is the current flowing through the conductor, and
R is the resistance of the conductor.
Code
<script type="text/javascript">
function calculate() {
var v = document.getElementById("voltage").value;
var i = document.getElementById("current").value;
var r = document.getElementById("resistance").value;
if (v == "") {
document.getElementById("voltage").value = i * r;
} else if (i == "") {
document.getElementById("current").value = v / r;
} else if (r == "") {
document.getElementById("resistance").value = v / i;
}
}
function clearFields() {
document.getElementById("voltage").value = "";
document.getElementById("current").value = "";
document.getElementById("resistance").value = "";
}
</script>
<style>
.ohm_container {
margin: auto;
width: 50%;
padding: 10px;
border: 2px solid #ccc;
text-align: center;
}
</style>
<div class="ohm_container">
<form>
<label for="voltage">Voltage (V):</label>
<input type="number" id="voltage"><br><br>
<label for="current">Current (A):</label>
<input type="number" id="current"><br><br>
<label for="resistance">Resistance (Ω):</label>
<input type="number" id="resistance"><br><br>
<input type="button" value="Calculate" onclick="calculate()">
<input type="button" value="Clear" onclick="clearFields()">
</form>
</div>
Leave a Reply