Go Down

Topic: Analog input 1 (Read 502 times) previous topic - next topic

ljbeng

I designed a shield for a customer and found I shouldn't have mixed the analog and digital the way I did.  I put a software serial on pin 14, analog input on pin 15 and another software serial on 16,17.

14 - serial lcd (9600 every loop writes to lcd)
15 - check voltage of battery 12v---switch---47K 1%---AN1---10K 1%---GND
16 - Serial rx (little used).
17 - Serial tx (little used).

Is there a way to shut the serial lcd serial port off, let things settle on the analog pins and then take an accurate reading?  Once the battery switch is closed, I could display "WAIT" on the lcd, stop writing to the lcd and take a measurment.  With battery check switch open, I am reading 1.25vdc on the AN1 pi while the lcd serial is sending data.

Thanks.

James C4S

Call flush() on the softwareserial object to make sure it is done sending characters before you call analogRead().
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

ljbeng

Fixed it.  I had pin 14 called out as Serial Tx and 15 as RX and AN1 input. (Interesting, it still read an analog value but had 1v on the pin all the time) I did not need RX so I just modified the SoftwareSerial setup.  Thanks.

Go Up