Go Down

Topic: Resistors sensorValue  (Read 772 times) previous topic - next topic

SmileXS4

Hello Friends!

I can't understand yet,how to calculate the sensorValue of a potentiometer.I know the converted value is a number between 0 and 1023 but how can I calculate it?For example:what is the sensorValue of a potentiometer that is fixed to 220 ohm?
I Already tried to change the blinking speed of an LED with a 10k potentiometer but it has got 3 pins...
Is this also possible with a resistor?

Thank you!

rpt007

Hi,

it's not the resistor value what is measured but the voltage drop which is fed back into the measuring pin.
The outer pins of the potentiometer are connected to +5V and GND and the middle pin to the input (=measuring) pin of the Arduino.

Quote
I Already tried to change the blinking speed of an LED with a 10k potentiometer but it has got 3 pins...
What about your knowledge in electronics? A potentiometer always comes with 3 pins.
The outer ones have the full resistor, the middle pin is turned between 0 and max resistor value.

Quote
I Already tried to change the blinking speed of an LED with a 10k potentiometer but it has got 3 pins...
Is this also possible with a resistor?
YES - if you want to have only one blinking frequency.
NO  - if you want to adjust the frequency (that's only possible with a potentiometer.

Before you ask:
Did you really read and understand How to use this forum ?
AND:
Do you have already some solution or is a part of the problem sitting in front of the screen?  :)

SmileXS4

Sorry,but I can't express myself.I'm not very good in english(in electronics also :) )I wanted to know if is possible to convert the voltage drop to sensorValue.

Thank you for the fast answer!

MarkT

[ I will NOT respond to personal messages, I WILL delete them, use the forum please ]

rpt007

Look at this:


Code: [Select]
/*
  ReadAnalogVoltage
  Reads an analog input on pin 0, converts it to voltage, and prints the result to the serial monitor.
  Graphical representation is available using serial plotter (Tools > Serial Plotter menu)
  Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
 
  This example code is in the public domain.
*/
 
// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}
 
// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  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.println(voltage);
}



In your case, just use the sensorValue itself, which will be a value between 0 and 1023.
If you need the exact voltage value, use the conversion command line:
float voltage = sensorValue * ...
Before you ask:
Did you really read and understand How to use this forum ?
AND:
Do you have already some solution or is a part of the problem sitting in front of the screen?  :)

terryking228

Hi,
See  THIS: with a lot of potentiometer info and Arduino code examples.
Regards, Terry King terry@yourduino.com  - Check great prices, devices and Arduino-related boards at http://YourDuino.com
HOW-TO: http://ArduinoInfo.Info

SmileXS4

Thanks a lot!The answers was really helpful for me. :)

Go Up