Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Problems with simple analog read circuit

  1. #1

    Problems with simple analog read circuit

    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.

    Click image for larger version. 

Name:	FullSizeRender.jpg 
Views:	153 
Size:	122.9 KB 
ID:	5461

    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)

    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:

    // 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:
    delay(1); // delay in between reads for stability

    Values output - from Serial Monitor (without touching pot)


  2. #2
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Ayer Massachussetts
    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).

  3. #3
    Senior Member
    Join Date
    Apr 2013
    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

  4. #4
    Thanks for your quick and helpful responses. It works now! The ground connection was just a silly mistake (I got it right first time, then rebuilt and connected it wrong). It seems I was looking at an incorrect pin layout (probably a different board) which explains my confusion with the pins

    Thanks again, much appreciated!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts