Reading Voltage and working with potentiometer for Arduino
The source code for controlling Potentiometer for Arduino
//Original source: https://www.arduino.cc/en/Tutorial/ReadAnalogVoltage
// This code is used with a video tutorial for RoboJax.com
// Published on April 24, 2017 from Aajx, ON, Canada.
// Written/Edited by A.B.S
// This Arduino
void setup()
{
Serial.begin(9600); // setup serial
}
void loop(){
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1023.0);
// print out the value you read:
Serial.print("Voltage =");// prins the text "Voltage ="
Serial.print(voltage);
Serial.println();
delay(300);
}
Project 2 Finding the resistance value from the voltage
//Original source: https://www.arduino.cc/en/Tutorial/ReadAnalogVoltage
// Project: Finding the resistance value from the voltage
// This code is used with a video tutorial for RoboJax.com
// Published on April 24, 2017 from Aajx, ON, Canada.
// Written/Edited by A.B.S
float RT = 50000;// the potentiometer value
float R;// the unknow R value
void setup()
{
Serial.begin(9600); // setup serial
}
void loop(){
int sensorValue = analogRead(A0);
// Convert the analog reading (which goes from 0 - 1023) to a voltage (0 - 5V):
float voltage = sensorValue * (5.0 / 1023.0);
// print out the value you read:
R = ( voltage * RT)/5.0;
Serial.print("Voltage =");// pritns the text "Voltage ="
Serial.print(voltage);
Serial.print("v R=");
Serial.print(R);
Serial.print(" ohms");
Serial.println();
delay(300);
}