Arduino Tutorial 2

Arduino ProgrammingIn this part of my Arduino tutorial I’ll cover how to measure current, resistance and voltage with a multimeter. I’ll also show how to measure voltage with an Arduino with a demonstration using a potentiometer and LED. To finish off I’ll show the difference between resistors in series versus parallel and a whole lot more.

All of the code used follows the video below.

If you like videos like this consider donating $1, or simply turn off Ad Blocking software. Either helps me to continue making free videos.

Code from the Video

// We can read the the voltage change caused by
// the potentiometer using an Arduino analog input

// The pin that will read the voltage coming from the
// breadboard and provide a value from 0 to 1023
// or 0 to 5V
int potInPin = 2;

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

void loop() {

  // Read input which will be 0 (0V) - 1023 (5V)
  int val = analogRead(potInPin);

  // Convert from 0 - 1023 to voltage 0 - 5V
  float voltage = val * (5.0 / 1023.0);

  // Convert from 0 - 1023 to resistance 0 - 10k
  float potPer = 10000.0 - (val * (10000.0 / 1023.0));
  
  Serial.print("Volts : ");
  Serial.println(voltage);

  Serial.print("POT % : ");
  Serial.println(potPer);

  Serial.println();
  delay(1000);
}

Leave a Reply

Your email address will not be published. Required fields are marked *