Pages: [1]   Go Down
Author Topic: Weird analog signals in LCD Keypad shield  (Read 913 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 1
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hello.

Yesterday got my LCD Keypad shield, link to product etc.:
http://www.robomaa.com/index.php?main_page=product_info&cPath=15_18&products_id=419
Instead of LCD4Bit library i used Arduino´s LiquidCrystal- library.
Made pin changes to code and everything worked just fine.

After i connected LM35Z temp sensor to analog input pin5 and tried to read signal that sensor outputs to Arduino the readings was pretty weird.
I stripped the program code to minimum, just read the analog signal and print it to LCD, but no.
It shows that incoming signal is 230-250 and nothing happens if i disconnect the sensor.
After hard thinking ang googling i tried program code which i made to that temp sensor.
Everything worked fine. Readings and conversions was ok.

After that i tried again that code which includes LiquidCrystal.h and readings got weird again.
So could you gurus help me with this problem?  smiley-grin I´m newbie with these, but i spent allmost whole workday today when tried to solve this problem but no nothing showed up.

I´ll paste that minimal program code here if there´s something wrong..

Code:
// include the library code:
#include <LiquidCrystal.h>

int tempSens = A0;
int tmp;

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

void setup() {
  pinMode(tempSens, INPUT);
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.clear();
}

void loop() {
  delay(500);
   tmp = analogRead(tempSens);
   lcd.setCursor(0,1);
   lcd.print(tmp);
}
Logged

The Udaho Border
Offline Offline
Newbie
*
Karma: 2
Posts: 18
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

After i connected LM35Z temp sensor to analog input pin5 and tried to read signal that sensor outputs to Arduino the readings was pretty weird.

...

int tempSens = A0;

...

pinMode(tempSens, INPUT);


If it's connected to analog input 5 shouldn't tempSens be initialized to A5?

A0 is used by that shield for the pushbutton inputs. I had to add some debouncing to the function for checking pushbuttons that's supplied with LCD4Bit library. The print routines supplied with the LiquidCrystal library also work better than those in LCD4Bit and I haven't needed anything not included in LiquidCrystal either.

I use A1 to read a position sensor attached to a linear actuator. I've had zero problems since I added a 0.01µF cap between the sensor output and ground. I found I didn't need to explicity set pinMode to INPUT. After doing so though, I'm curious as to whether a digitalWrite(tempSens, LOW) would be needed to clear the pull up resistor.
Logged

Portugal
Offline Offline
God Member
*****
Karma: 6
Posts: 962
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

And you must use itoa, because you are reading an int value but you want to print a small string..
Logged

Offline Offline
Newbie
*
Karma: 1
Posts: 8
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
If it's connected to analog input 5 shouldn't tempSens be initialized to A5?

Sorry, forgot to mention that i tried to read analog signal from different pins and that A0 was in that code because it was a last pin which i tried.

But so far so good.
Fisrt i added this line, digitalWrite(tempSens, LOW) to code and after that attached 1µF cap between the sensor output and ground and... Võila. Reading stays seady and shows right temperature. smiley-cool

Also added some text when press select button and no more weird analog signals, thanks to that cap.

Looks like this problem is solved now and i can move on with my projects.

Thank you very much!!
Logged

Taiwan
Offline Offline
Newbie
*
Karma: 0
Posts: 5
Android & Arduino
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I have same problems on LCD Keypad with temperature sensor. I can not understand where the 1uF Cap was added on.
Could you show me the circuit? thanks!
Logged

Pages: [1]   Go Up
Jump to: