analogRead() returns nothing

Here are two lines of my code:
USART_println(“ans:”);
USART_println(analogRead(A0));

The result i get is (the script is being looped):
ans:ans:ans:ans:ans:ans:ans:ans:ans:

I have checked my pins and am sure they are connected correctly.
I have tried 2 different sensors. I am writing the code in C using VScode.

Does anyone have an idea why analogRead returns nothing?
I have included <Arduino.h>

What is the argument type of the function USART_println()? Is it const char* or String?

If the function expects a const char* for example, you need to make it a string first (e.g. by using snprintf() first). Otherwise your integer value is reinterpreted as a pointer to some memory address where there’s garbage.

2 Likes