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

Thread: Error analog input

  1. #1
    Junior Member
    Join Date
    Jan 2014

    Error analog input

    I have a teensy++ 2.0 and I tried the code given in one of the tutorial :

    void setup()

    int val;

    void loop()
    val = analogRead(0);
    Serial.print("analog 0 is: ");

    It's said in the tutorial that the value should be 0 when is at 0 volts.
    However, when nothing is connected to the pin (and the other pins) I get something like this :

    analog 0 is: 386
    analog 0 is: 373
    analog 0 is: 374
    analog 0 is: 368
    analog 0 is: 380
    analog 0 is: 378
    analog 0 is: 376
    analog 0 is: 368
    analog 0 is: 345
    analog 0 is: 342
    analog 0 is: 365
    analog 0 is: 359

    Do you have any idea of where the problem might come from ?
    Thanks in advance.

  2. #2
    Senior Member+ MichaelMeissner's Avatar
    Join Date
    Nov 2012
    Ayer Massachussetts
    It sounds like you have a floating ground. There must be a connection to ground as part of any analog circuit. Here is one of the first articles that popped up when I did a goggle search for floating input:

  3. #3
    Senior Member
    Join Date
    Jan 2014
    London, UK
    If nothing is connected the the Analog pin, then you are picking up all the EM radiation in the room much like an antenna. If you want to read 0 volts it must (as Michael has said) be connected to the ground, which is where 0V is as far as your circuit is concerned.

    Google for information about voltage dividers (or potential dividers if in the UK) to get a better idea of analogue circuits

Tags for this Thread

Posting Permissions

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