Cant get any meaningful analog readings (novice user)

Status
Not open for further replies.
Teensy 3.6


I am just trying to test out a potentiometer with this simple code:
Code:
void setup() {
  Serial.begin(9600);
}

void loop() {
  Serial.println(analogRead(A0));
  delay(1000);
}

Ive tried outside leads to 3.3v (normal, or 250ma max) and analog ground, and inside lead to both a0 and a1 (at diffrent times with different code) and all i get are random numbers between 400 and 700.

Nothing connected

A0 to analog ground

A0 to 3.3v

Tried different very similar examples

Tried responsive analog read example.

Reading of random numbers from 400 to 700 every time.

Not sure what im doing wrong. Digital reads work correctly btw and tested sending midi data to ableton.
 
Nothing 'wrong' that I can see in how you're going about it.

Does moving the wiper make any difference in the 'random' output?

Have you tried another pot?

Pins 14 and 15, correct? Because it sounds like a floating pin reading stray voltages.
 
Turning the potentiometer has no effect.

Yes 14 and 15. I have tried using all combinations of pin 0,1,A0,A1,14,15. ( I mean in code as arguments for the functions)

This is the only potentiometer I have until tomorrow, but i looked this problem up in another thread and they said a0 to aground should read 0, and a0 to 3.3v should read something like 1023. Even in these cases I get random values 400-700.
3bUJ9tu
 
Hey guys, I'm not sure what the rules are for bumping here and didn't see anything in the faq; so let me know if this is a prob but I'm back at this issue again today.

My digital button reads still work and send midi to Ableton, blink example still works, so i know my teensy didn't blow up or anything.

j01VtPd.jpg


That is the setup, the right side is the potentiometer, the left side is a button for a digital sketch.

This is the current code:
Code:
/*
  AnalogReadSerial

  Reads an analog input on pin 0, 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.

  http://www.arduino.cc/en/Tutorial/AnalogReadSerial
*/

// 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);
  // print out the value you read:
  Serial.println(sensorValue);
  delay(100);        // delay in between reads for stability
}

Tried different wires also.

Still random numbers, can anyone help please?

Edit: I have a breadboard power module... should i try a 5v setup?
 
No 5V, this will kill the analog inputs.

From your picture, I see one end of the pot connected to +3.3V with a red wire. I see the wiper of the pot connected to teensy pin A0 with a black wire. I see the other end of the pot connected to NOTHING??? but should be to GND with a white wire.

And I see that the breadboard pins seem not to be soldered to the Teensy which is the best way to have bad, intermittent or no contact at all.

Looks not very serious or professional!
 
Looks like there's a not-so-easy-to-see white wire between the breadboard rail and AGND.

Pretty sure this will work once the pins are soldered.

 
@Ongaku - adding the picture answered a lot of questions as you can see - adding more useful detail is good to get better feedback - not having the pins soldered results in intermittent connections at best.

Thierry - you'll note the thread title … (novice user)

OH YEAH - there are wires blending in there ...
 
Novice user in the title was interpreted by me as novice with the Teensy. That doesn't have to be a contradiction to owning a brilliant diploma in engineering sciences... :cool:
 
Ok yah, this is like my first time with a breadboard since elementary, I was hoping I would not have to solder yet cus I'm still in the planing phase and I'm not sure if I want pins like this, or headers on the teensy, but I guess I gotta solder them NOW to test it fully.

I solder very often so this isn't a prob, but I rarely desolder. Just weird the digitals work perfect but the analog doesn't, I guess it is more sensitive to having a soldered connection.

Well thx, I will try soldering and see, hopefully that works, cus I don't think I can return it after that.

Edit: So according to the vid, flux isnt used for this?
 
Works like a charm, thx guys. Im sure ill be back, my project is relatively ambitious for my level of experience in this. Hopefully what im trying to do isnt THAT complex.... just some buttons, pots, a tft, and lots of leds (which i assume will be the toughest as far as power management goes).
 
Status
Not open for further replies.
Back
Top