I had my 2x16 character LCD from Sparkfun working a few weeks ago, but now that I've re-programmed my arduino connected to it, it no longer is working with the code. I am using the 'LiquidCrystal' library and an ATmega328. When I start it up, the LCD is just all darkened (every pixel). Even if I call 'lcd.clear()', nothing happens. All I am able to do is activate the backlight. What is wrong? I quadruple-checked the connections, I SWEAR. Here's my code:
#include <LiquidCrystal.h>
//#include "LCD4Bit.h"
#include <Wire.h>
LiquidCrystal lcd(11, NULL, 12, 7, 8, 9, 10);
byte i;
int backlight = 6; // Digital 6
int battery;
void setup()
{
lcd.print("HELLO");
lcd.clear();
Wire.begin(4); // join i2c bus with address #4
Wire.onReceive(receiveEvent); // register event
Serial.begin(9600); // start serial for output
pinMode(backlight, OUTPUT);
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
}
void loop()
{
delay(100);
}
// function that executes whenever data is received from master
// this function is registered as an event, see setup()
void receiveEvent(int howMany)
{
char c = Wire.receive(); // COMMAND
switch(c) {
case 'D':
battery = Wire.receive();
lcd.clear();
lcd.print(battery);
break;
case 'B':
boolean bcklt = Wire.receive();
digitalWrite(backlight, bcklt);
break;
}
}
Ignore all but the parts dealing with the LCD. Thanks
perhaps the new code is the issue? Try opening up one of the example sketches for the lcd library and testing that (change the pin values in the code to correspond with your setup, of course) - that'll tell you if the problem is software side or hardware side.
Are you using a different library from the one that worked before?
If you are using the latest LiquidCrystal that Limor has been working on, this needs to be wire differently from the distributed version of LiquidCrystal. see http://arduino.cc/en/Tutorial/LiquidCrystal
I have tried opening an example sketch, but it doesn't work with that either. I have taken note to change the pin declarations in all cases as well. I took a look at the liquidcrystal libraries, and the examples on the arduino site (like the one here: http://arduino.cc/en/Tutorial/LiquidCrystalBlink) only have SIX arguments within the initialization of 'LiquidCrystal lcd(). I don't understand this, because the versions I have come across don't allow that; they have to have the RW pin declared (which I put 'NULL' for...I believe I was having this problem a while back and someone told me to put that, at which the problem, then, was solved). I am not using the RW pin. There is a note on each liquidcrystal tutorial page that says users of Arduino 0017 don't have to download the new liquidcrystal library. Is that the only place to get the new library? I can't even FIND Arduino 0017...is it in alpha/beta release stages?? What do I do? Do I need to use the R/W pin? Get the new LiquidCrystal library? I KNOW my hardware is hooked up right! :-[
Ok, the Arduino IDE NEEDS SOME WORK. And if I knew Java, heck I'd spend a few hours on it because it is giving me a slew of errors and problems that it SHOULDN'T. But, alas, I am in high school and I can only do so much haha.
Anyways, here's the deal: I ran both of the 'LiquidCrystal' library examples. THEY work because it seems Arduino is looking at the right LiquidCrystal library (that's my theory). But when I create my OWN sketch, go into the context menus, and select 'import sketch-->liquidcrystal, using the 'lcd.write' command doesn't work; Arduino tells me that the command doesn't exist (which leads me to believe it is looking at a different version of the library). I have also tried to drag-and-drop the libraries (from MULTIPLE locations) into the IDE (which adds them on the 'tabs'). No dice. I tried moving around the liquidcrystal library, putting it in the same folder as my sketch; didn't work. I am using 'lcd.write()' instead of 'lcd.print' because 'lcd.print' does NOT work. I am guessing these are the same commands, but just different names for the same syntax in different releases (old and new) of the liquidcrystal library...?
My HARDWARE is fine, my SOFTWARE is fine; ARDUINO and the way it handles libraries, is NOT. WHAT must I do to solve this issue? >:(
Ok solved that problem...Sort-of. Now it's giving me this ridiculous error: "Couldn't determine program size: C:\Documents and Settings\Reece.SEBASTION-JR\My Documents\DIY\Programming\arduino-0016\hardware/tools/avr/bin/avr-size: 'C:\DOCUME~1\REECE~1.SEB\LOCALS~1\Temp\build62050.tmp\SLAVE.hex': No such file"
I swear I am loathing this Arduino software, and I'm SERIOUSLY considering just learning AVR Studio!!! Not only this, but Arduino CONTINUALLLY freezes on my computer at random times when I click 'upload sketch'. WHAT IS WRONG?!
I have a project I am working on for an internship, and I love the Arduino software environment, and what's even better is that it is open source. But I CAN"T have these continual bugs; I have a week left to do this and I am barely started!!
I need to solve these two VERY PRESSING problems:
Stop Arduino software from freezing upon sketch uploads
Determine what Arduino is trying to tell me/how to fix the problem of the 'no such file' error.
The best advice I can give to quickly solve your problem is to turn your computer off for half an hour and go for a walk.
When you come back, try to compile and run one of the simple example sketches like the digital blink example. If that doesn't work, try the suggestions in the troubleshooting section: http://www.arduino.cc/en/Guide/Troubleshooting
I have the same problem... when I try to compile blink sketch I get error message like this:
o: In function loop': C:\WINDOWS\TEMP\build41897.tmp/Temporary_2269_8910.cpp:52: undefined reference to LiquidCrystal::setCursor(unsigned char, unsigned char)'
Couldn't determine program size: E:\Arduino\arduino-0016\hardware/tools/avr/bin/avr-size: 'C:\WINDOWS\TEMP\build41897.tmp\HelloWorld.hex': No such file
but everything work fine when I remove this two lines:
Artur, you are probably using the old library that was distributed with 0016, not the new one that Limor did. Those functions are not in the old version.
A common cause of the problems you and Quackmaster are seeing can be due to incompatible versions of sketches and libraries.
If so, try compiling one of the example sketches for your version of the library. That may be easier said then done because there are subtle differences in wiring and the example code in earlier versions of LiquidCrystal and you really need to make sure that the library code matches the example code matches the wiring. I am quite sure that if you get all three consistent you will have your LCD working again.
Thanks mem. Yes, it is working now. I am having problems with the arduino software now, as it gives me the "blah blah......____.hex does not exist error EVERY SINGLE TIME I try to upload a sketch. There is this little squiggly character that appears on the sketch tab when I open a program, but when I save the program, it disappears. When it is not there, it seems arduino almost always gives me this error. I know this has something to do with where the files are saved...maybe?
Those errors may be caused by missing files or files with code errors in one or more libraries.
Do you have a library that has the same base name (name without the .hex extension) as the error message? If so, temporally remove the library from the libraries directory and if the error disappears then you need to fix an error in that library.
You can use Eclipse as your IDE (Arduino Playground - Eclipse), I find it saves a lot of mucking around as the Arduino IDE doesn't have many features (the most annoying being only having one sketch available at a time
If anyone else is having the LCD issues, I found a tutorial which suggested the following code and connecting it as the setup implies (as the tutorials from Sparkfun and Seeed weren't working):
Jamie, you will be pleased to know that the IDE for the next Arduino release supports multiple open sketches. The release candidate is being tested now and the release should be available soon.
The LiquidCrystal library for that release is also being updated to the code linked in post #4 so the extra delays should not be necessary. Did you try that code?