A* 32u4 prime SV Analog in Print to LCD

I am new
I am trying to read a analog input (humidity sensor) on A3 of my A* prime and take the value and move it to the LCD that i purchased along with the A*. I attached some code i cobbled together. I took the “hi” “1234” and tweaked it to print the A3 value on line 2 and put humidity instead of hi. Simple enough. What if I want a percent sign next to my value? Because now it reads
Humidity
21
However, I have no way of viewing the raw value or knowing if this is real? as it stays solid at 21.
LCDBasics_a3_write.ino (730 Bytes)

Hello.

I briefly looked at your code, and it looks like you are printing the value of A3 instead of reading from the analog pin A3. The outermost rows of pins of the A-Star 32U4 Primes correspond to the pins on an Arduino Leonardo and are defined by the Arduino Leonardo’s system header file in pins_arduino.h, so the value 21 is just the digital pin number for A3; not a raw value from your humidity sensor.

To output values from your humidity sensor, you need to define A3 as an input, and then use analogRead() to read the analog value on pin A3. For example:

pinMode(A3, INPUT);
lcd.print(analogRead(A3));

You can find more information about the analogRead function (as well as other functions that might be helpful to you) on the Language Reference page from Arduino’s website.

- Amanda

AmandaS,

Thank you so much for your kind advice! That makes so much more sense, I had it exposed to humid environment and then buried in desiccant, still 21. LOL! I will look around the link you attached and the segment of code you included. Thanks again.

half hr later

Made some edits and it works more like i believe it should constant movement of the variable 3 digits when exposed to desiccant drops,

awesome!

now on to the next step, make the sensor wireless

JM
analog_print_lcd.ino (886 Bytes)