system
March 20, 2014, 3:05am
1
im new to using arduinos and whenever i use the serial monitor it displays a value around 300 and drops to about 170 and stays that way every time i try to use it with anything like a potentiometer or a photo resistor.
i have been using the sketch in the arduino library
void setup()
{
Serial.begin(9600);
}
void loop()
{
int sensorValue = analogRead(A0);
Serial.println(sensorValue);
delay(1);
}
Are you sure you are using the right analog pin. Seems to me that A0 is floating.
sensai
March 20, 2014, 3:13am
3
pYro_65:
Are you sure you are using the right analog pin. Seems to me that A0 is floating.
I actually made that mistake first time I hooked up a potentiometer, I plugged it into A5 instead of A0, al because I didn't read the board. LOL
system
March 20, 2014, 7:31am
5
raschemmel:
How about a photo ?
Or a schematic. Or something pretty to look at.
system
March 24, 2014, 2:34am
6
that's exactly how i have it setup. i have tried allot of the examples from the arduino library, following the schematics exactly and it still wont work. i even tried to use a servo with no success at all. could this be a problem with my board?
LarryD
March 24, 2014, 2:58am
7
Still would be nice to see the actual set up in a picture.
Have you tried to use a different input?
system
March 24, 2014, 3:55am
8
LarryD:
Still would be nice to see the actual set up in a picture.
Have you tried to use a different input?
Or a different potentiometer?
sensai
March 24, 2014, 5:20am
9
is it possible you got your potentiometer upside down? The middle is easy but perhaps the other two are, backwards ?
It should work, either way.
Try another analog input.
Get a voltmeter and see what the actual voltage is. Maybe the pot is broken somehow.
Robin2
March 24, 2014, 8:29am
11
Try increasing delay(1) to delay(1000).
These are milliseconds, and 1 millisecond is very short.
...R
Some servo/pot test code you can try to see if you can get the servo values output to the serial monitor (you don't need servos to try the code).
//zoomkat dual pot/servo test 12-29-12
//view output using the serial monitor
#include <Servo.h>
Servo myservoS1;
Servo myservoS2;
int potpinS1 = 0; //analog input pin A0
int potpinS2 = 1;
int newvalS1, oldvalS1;
int newvalS2, oldvalS2;
void setup()
{
Serial.begin(9600);
myservoS1.attach(2);
myservoS2.attach(3);
Serial.println("testing dual pot servo");
}
void loop()
{
newvalS1 = analogRead(potpinS1);
newvalS1 = map(newvalS1, 0, 1023, 0, 179);
if (newvalS1 < (oldvalS1-2) || newvalS1 > (oldvalS1+2)){
myservoS1.write(newvalS1);
Serial.print("1- ");
Serial.println(newvalS1);
oldvalS1=newvalS1;
}
newvalS2 = analogRead(potpinS2);
newvalS2 = map(newvalS2, 0, 1023, 0, 179);
if (newvalS2 < (oldvalS2-2) || newvalS2 > (oldvalS2+2)){
myservoS2.write(newvalS2);
Serial.print("2- ");
Serial.println(newvalS2);
oldvalS2=newvalS2;
}
delay(50); //slow down looping to better read serial monitor
}
system
March 25, 2014, 1:37am
13
Try connecting A0 directly to 5V and confirm analogRead() returns a value close to 1023, and then connect it to GND and confirm it returns a value close to zero.
If it passes those tests, there's something wrong with your pot or the way you've connected it. If it fails the test, there's something wrong with your Arduino.
system
March 26, 2014, 10:30pm
14
ok, i was able to try out another arduino and everything worked perfectly so its probably a broken arduino board.