Potentiometer and Op Amp (noob) :)

Hey everyone, I have with me a LM358N dual op amp and a small potentiometer. I have this circuit; 3.3v connected to potentiometer, which is hooked up to analog 2, and the final connection goes to Non inverting input A on my opamp. ( http://yyao.ca/projects/motor_controller_tachometer/img/NonInvertingOpAmp.png ) this is a link to my circuit diagram (not including potentiometer, which is Vin, and I have the arduino's 5v connected to V+ as i have no external power supply) The code below prints voltage reading from potentiometer to my terminal when i did not have the op amp. How do i change the code to allow me to change voltage with potentiometer and get an accurate reading of the boosted signal using the op amp?

void setup() { Serial.begin(9600); //begin serial communications. } void loop() { int sensorValue = analogRead(A2); //read input on analog pin 2 float voltage = sensorValue * (3.3 / 1023.0); //convert analog reading (0-1023) to voltage (0-5v) Serial.println(voltage); //prints the voltage to serial monitor }

It's not clear to me why you are adding an op-amp to the circuit.

Which voltage are you trying to measure? The one coming out of the potentiometer or the one coming out of the op-amp?

How do i change the code to allow me to change voltage with potentiometer and get an accurate reading of the boosted signal using the op amp?

You don't need a software change, you need a hardware change... Just connect the analog input pin (A2) to to the output of the op-amp, instead of connecting to the pot, and you'll be reading the op-amp output.

Or, you can change the hardware and software... Connect the op-amp output to a different analog input, read them both, and calculate both voltages.

This line looks wrong.

float voltage = sensorValue * (3.3 / 1023.0); //convert analog reading (0-1023) to voltage (0-5v)

If you are using the default internal 5V A/D reference, 3.3 should be changed to 5.

For example, with 2.5V on the input, the A/D will read half of its maximum of 1023 (about 512). 512 x 5/1023 = 2.5.

NOTE - With a single 5V power supply, your op-amp will be limited to between 0 and 5V... Actually, it won't quite go down to zero and it won't quite go up to 5V. So for example, if you have a gain of 2 and you put-in 3V from the pot, you might expect an output of 6V. But since the op-amp can't put-out 6V, it will "saturate", and you'll get around 5V.

johnwasser: It's not clear to me why you are adding an op-amp to the circuit.

Which voltage are you trying to measure? The one coming out of the potentiometer or the one coming out of the op-amp?

Hey, i quoted your comment on my last post, i appreciate the patients. Read what i posted, and it should make a little more sense. I need to turn the voltage up/down to speed the acceleration of vibration (more specific detail of this on my other quote on my other topic) and have it change the sine wave on my comp screen. This is just to simply practice the basics of the project i have ahead of me, as i have no background with Arduino. I appreciate you taking the time to assist :)