Pages: [1]   Go Down
Author Topic: Arduino Analog Inputs acting funny (random noise)  (Read 785 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm trying to get some reading from a pot using the example sketch and it is not working. It might be possible that my board is shot.

Here is the sketch:
Code:
void setup() {
  Serial.begin(9600);
}

void loop() {
 
  int sensorValue = analogRead(A1); 
 
  Serial.print("1 ");
  Serial.println(sensorValue);
 
  delay(100);
 
}

When I run it and have nothing plugged into A1 the reading is around 340 and only varies slightly. When I plug in a wire and have the wire laying there not connected to anything the readings jump from 200s to 500s. When I grab the wire insulation the readings go even crazier.

video here:
Logged

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 331
Posts: 16514
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That is normal. When you have nothing electrically wired to a analog pin it is said to be in a floating input pin condition and will be subject to reading random electrical noise. Wire the analog input pin to ground or +5vdc and see how steady the readings become. What and how you wire things to the analog input pin is important, if you expect them to work correctly.

What is the ohm value of the pot you are trying to use and how have you wired it up? 10k or less is the pot value you should be looking for.

Lefty
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay. That makes sense. I guess I should move this out of troubleshooting then.

I need to start a new thread about why this still happens when I solder that pin to the pot on a xbox 360 controller. The readings look exactly the same. Do I need to take the 3.3v from the controller to the AREF?
Logged

Left Coast, CA (USA)
Online Online
Brattain Member
*****
Karma: 331
Posts: 16514
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Okay. That makes sense. I guess I should move this out of troubleshooting then.

I need to start a new thread about why this still happens when I solder that pin to the pot on a xbox 360 controller. The readings look exactly the same. Do I need to take the 3.3v from the controller to the AREF?

Did you also wire a ground wire from the arduino to the xbox? That would be required.

Lefty
Logged

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 508
Posts: 31416
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Have a read of this:-
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks Lefty. That did the trick. Works like a charm.

Mike, thanks for the link. I learned something.
Logged

Pages: [1]   Go Up
Jump to: