Go Down

Topic: LCD does not work unless Arduino is reset. (Read 6 times) previous topic - next topic

liudr

strange. I start to suspect your code or other hardware but I know you checked thoroughly. I buy from chinaecomponents on ebay. Never a problem.

dc42

I still thihk the problem is that the device is not ready when the begin() command send commands to the device. I suggest trying the following, one at a time:

1. Make sure you have a call to lcd.begin(...) in setup - assuming your LiquidCrystal variable is called "lcd".

2. Add a delay in setup() before the begin(...) call as per retrolefty's suggestion.

3. If that doesn't fix it, the problem may be that the lcd.begin() call in the LiquidCrystal constructor is happening too soon. Preferably, recompile the LiquidCrystal library with the begin() call at LiquidCrystal.cpp line 82 commented out. Alternatively, the following may work (it compiles but is otherwise untested):


  • Replace the declaration "LiquidCrystal lcd(...);" by the following:



Code: [Select]
void* operator new(unsigned int sz)
{
  return malloc(sz);
}

LiquidCrystal *pLcd;

  • Put the following in setup, before the lcd.begin(...) call:


Code: [Select]
  delay(1000);    // delay as per retrolefty's suggestion
  pLcd = new LiquidCrystal(...);   // insert correct pin numbers here

  • Replace every instance of "lcd." by "pLcd->"

Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

dtokez

hey there. I do have a call to begin in the set-up.

I have tried al sorts of delay times before the begin but does not seem to help

I not sure how I recompile the library?

I just tried the last suggestion, replacing some of the bits but could not get that too complie :(


dc42

#18
Sep 05, 2011, 01:40 pm Last Edit: Sep 05, 2011, 01:41 pm by dc42 Reason: 1

I just tried the last suggestion, replacing some of the bits but could not get that too complie :(


What compile errors are you getting, and on what lines? If you post your sketch, I can try making the changes and see what problems there are compiling it.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.

dtokez

Hi there, here is what I have currently

Code: [Select]
#include <LiquidCrystal.h>
void* operator new(unsigned int sz)
{
  return malloc(sz);
}

LiquidCrystal *pLcd;


//LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

int analoginput = 0;
int analoginput1 = 1;
int analoginput2 = 2;
float vin = 0.0;
float vin1 = 0.0;
float vin2 = 0.0;

void setup(){
  delay(1000);    // delay as per retrolefty's suggestion
  pLcd = new LiquidCrystal(7, 8, 9, 10, 11, 12);   // insert correct pin numbers here
 
 
delay(100);
pLcd.begin(16, 2);
delay(100);


    pLcd.setCursor(0, 0);
   pLcd.print("REAPsystems V1.1");
       lcd.setCursor(0, 1);
   pLcd.print("iSensor tester");
   
   
delay(4000);
   
   
   
  pLcd.clear();

}



void loop(){
 
 
     delay(1400);


// read the value on analog input
pLcd.setCursor(0,0);
pLcd.print ("Vin:");
vin = analogRead(analoginput)*5.00/1024*2;
pLcd.print(vin, 3);
pLcd.print ("v");

pLcd.setCursor(0,1);
pLcd.print ("R:");
vin1 = analogRead(analoginput1)*5.00/1024;
pLcd.print(vin1, 2);
pLcd.print ("v");


pLcd.setCursor(9,1);
pLcd.print ("O:");
vin2 = analogRead(analoginput2)*5.00/1024;
pLcd.print(vin2, 2);
pLcd.print ("v");


delay(1400);

}

Go Up