Problems with simple analog read circuit

Status
Not open for further replies.

unicornpower

Well-known member
I'm trying to experiment with building my own USB MIDI controllers and from my limited research, TEENSY seemed a good place to start. I've set up the simplest circuit I can on a breadboard, using a 100k linear pot connected to 5V and ground, with the centre pin going to the analog input. If I try and read the value at the input it seems to just be noise. If I dial the pot all the way in one direction I can actually make the TEENSY freeze (which suggests something is shorting?). I tried to add a 10k resistor between the pot and ground (I saw this mentioned somewhere else.) But that didn't appear to help. My electronics knowledge is rather minimal so any help would be appreciated.

FullSizeRender.jpg

I wrote a small C program to use MIDI, but that didn't work. So I tried the included example code. (and set the USB port back to Serial)

/*
AnalogReadSerial
Reads an analog input on pin 0, prints the result to the serial monitor.
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);
// print out the value you read:
Serial.println(sensorValue);
delay(1); // delay in between reads for stability
}


Values output - from Serial Monitor (without touching pot)

138
147
80
124
123
105
159
116
39
 
Your problem is the ground wire is not connected to the analog device. You have the wire connecting to the wrong side of the board. On breadboards, the two sides are not connected across the gulch separating the two sides. Similarly on most breadboards, the power lines (the red/black lines on the outermost two rows on each side). Typically, you would need to connect the red row on the left side to the red row on the right side, and similarly for the black and black (there are some breadboards/protoboards that have an option to connect the power lines).
 
Several other things to look at:
You don't actually have anything connected to pin A0. You need the pot wiper (center) connected to the Teensy analog input you are reading (see reference card). Out of the other inputs you need one side to ground, as MichaelMeissner has noted.

The other one needs to connect to 3.3V. You have one connected to 3.3V and one connected to five volts and when you wind the pot so they are close the 3.3V regulator dies.

Hope that you haven't killed it in the course of that.

Out of date since it talks of 5V where the Teensy is 3.3 but see https://www.pjrc.com/teensy/tutorial4.html
 
Status
Not open for further replies.
Back
Top