Issues with Analog Port

Hi

I have designed and manufactured a custom board for one of my projects. The board features Atmega-328-AU microcontroller and is programmed using Arduino IDE.

The issue I am facing is that none of the analog port responds to analogRead(port) function, whereas, if I check the voltage across the pins externally using DMM I can see the voltage variation.

The board does not feature TX/RX pins therefore I cannot use serial monitor.

Can anyone please help me out with this issue like what I am exactly missing.

Please post your full sketch.

If possible, you should always post code directly in the forum thread as text using code tags:

  • Do an Auto Format (Tools > Auto Format in the Arduino IDE or Ctrl + B in the Arduino Web Editor) on your code. This will make it easier for you to spot bugs and make it easier for us to read.
  • In the Arduino IDE or Arduino Web Editor, click on the window that contains your sketch code.
  • Press "Ctrl + A". This will select all the text.
  • Press "Ctrl + C". This will copy the selected text to the clipboard.
  • In a forum reply here, click the "Reply" button.
  • click on the reply field.
  • Click the </> button on the forum toolbar. This will add the forum's code tags markup to your reply.
  • Press "Ctrl + V". This will paste the sketch between the code tags.
  • Move the cursor outside of the code tags before you add any additional text to your reply.
  • Repeat the above process if your sketch has multiple tabs.

This will make it easy for anyone to look at it, which will increase the likelihood of you getting help.

If the sketch is longer than the 9000 characters maximum allowed by the forum, then it's OK to add it as an attachment. After clicking the "Reply" button, you will see an "Attachments and other settings" link that will allow you to make the attachment.

When your code requires a library that's not included with the Arduino IDE please post a link (using the chain links icon on the forum toolbar to make it clickable) to where you downloaded that library from or if you installed it using Library Manager (Sketch > Include Library > Manage Libraries in the Arduino IDE or Libraries > Library Manager in the Arduino Web Editor) then say so and state the full name of the library.


Please provide a detailed description of the circuit on the analog pin, including exactly which pin on the ATmega328 is in use. Ideally, this would be in the form of a schematic (picture of a drawing on paper perfectly acceptable), but since this is likely to be a very simple circuit even a text description should be sufficient.

usmanqadir91:
The issue I am facing is that none of the analog port responds to analogRead(port) function, whereas, if I check the voltage across the pins externally using DMM I can see the voltage variation.

How do you know that it does not read it correctly? It might control e.g. a relay but we don't know. Please post a schematic.

usmanqadir91:
The board does not feature TX/RX pins therefore I cannot use serial monitor.

Lesson learned :wink: Always try to add a form of test points; unless pin count is at a premium, it would not cost you much to at least have GND, TX and RX on a three pin header on your board to connect a FTDI adapter; you don't have to put the header on (if you want to save costs).

Hi

Thank you for your reply

I am using a very simple code to read data from analogPort for a force sensitive resistor and then toggle a digital pin high if the threshold is crossed. However, the digital pin never get high no matter how much force I apply. I have read the data across FSR using DMM it show variations. Even the variations can be read on pins of atmega 328.

Pin # 27 of atmega is used via a voltage division circuit for FSR

OK, well good luck with your project.

If you will not post your code and a schematic, no one can help you.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.