Pages: [1]   Go Down
Author Topic: Analog input 1  (Read 493 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Fort Lauderdale, FL
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6144
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Call flush() on the softwareserial object to make sure it is done sending characters before you call analogRead().
Logged

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.c

Offline Offline
Newbie
*
Karma: 0
Posts: 18
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: