The Shop > Electronics & IC Programing

Arduino help

(1/3) > >>

John Rudd:
Guys,
Just spent some of my har earned cash on an Arduino Mega and lcd board...

I'm trying ot get the lcd board to fire up...I've downloaded some code that's supposed to write to the Arduino and using the push buttons on the lcd shield alters the display...Trouble is I've placed the library files in the appropriate place but when I load and compile I get a load of errors, susbsequently it wont complie and upload to the Arduino...
So,
1) what am I doing wrong?
2) does anyone have any working code I can uplaod to test out the Arduino and lcd shield please?

Thanks

RodW:
John,

The libraries should go in a separate folder under the Libraries folder as in:

D:\arduino-1.0.5\libraries

I am pretty sure you can also import a library from a zip file which unzips the files and puts them in the same folder but I generally do it myself.

To use the library you need to make sure it is included. You can do this under the Sketch/Import Library menu.

All this does is add the appropriate #include statement to include the library header file(s).

Post a link to the board you have purchased. I think all you need to do is include the LiquidCyrstal Library with this statement


--- Code: ---#include <LiquidCrystal.h>
--- End code ---

Once a library is imported, the examples that come with it appear under the File/Examples menu. start by running that.

eg. File/Examples/LiquidCrystal/HelloWorld will give you this.


--- Code: ---/*
  LiquidCrystal Library - Hello World
 
 Demonstrates the use a 16x2 LCD display.  The LiquidCrystal
 library works with all LCD displays that are compatible with the
 Hitachi HD44780 driver. There are many of them out there, and you
 can usually tell them by the 16-pin interface.
 
 This sketch prints "Hello World!" to the LCD
 and shows the time.
 
  The circuit:
 * LCD RS pin to digital pin 12
 * LCD Enable pin to digital pin 11
 * LCD D4 pin to digital pin 5
 * LCD D5 pin to digital pin 4
 * LCD D6 pin to digital pin 3
 * LCD D7 pin to digital pin 2
 * LCD R/W pin to ground
 * 10K resistor:
 * ends to +5V and ground
 * wiper to LCD VO pin (pin 3)
 
 Library originally added 18 Apr 2008
 by David A. Mellis
 library modified 5 Jul 2009
 by Limor Fried (http://www.ladyada.net)
 example added 9 Jul 2009
 by Tom Igoe
 modified 22 Nov 2010
 by Tom Igoe
 
 This example code is in the public domain.

 http://www.arduino.cc/en/Tutorial/LiquidCrystal
 */

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

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
  // set up the LCD's number of columns and rows:
  lcd.begin(16, 2);
  // Print a message to the LCD.
  lcd.print("hello, world!");
}

void loop() {
  // set the cursor to column 0, line 1
  // (note: line 1 is the second row, since counting begins with 0):
  lcd.setCursor(0, 1);
  // print the number of seconds since reset:
  lcd.print(millis()/1000);
}

--- End code ---

You need to look at this statement


--- Code: ---// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
--- End code ---

and make sure the pin definitions agree with your LCD display.

I would start with the LiquidCrystal examples and make sure that works before moving on. You may need to also turn the backlight on and stuff like that to begin with.

DMIOM:
John,

If it won't even compile, I'd try to simplify things; and in fact I'd suggest forget the LCD to start with.

Try and get it to compile, and then run, a program to flash an LED - that way you can prove the compile-load-run cycle.

Sample programs are available in the refererence section of the Arduino website  arduino.cc

I'd have a look at http://arduino.cc/en/Reference/DigitalWrite and try that example (you may need to change the pin number for the Mega's built-in LED).

One thing you need check which can cause compilation errors (if you haven't already done so) is to make sure the correct board type is chosen under the Tools | Board menu in the IDE

Dave

RodW:
Also check the USB port is setup correctly and the COM port number in the IDE agrees with what it actually is. There is a good tutorial on setting this all up on the Arduino web site.

John Rudd:
Ok, here's a bit more info...

The lcd file I was attempting to use is here: http://droboticsonline.com/ebaydownloads/LCD4Bit_mod.zip

When I attempt to compile it it wont without listing errors...Maybe some one can tell from that code what is going wrong?

I've identified my board in the IDE as a Mega2560, and is on COM4.
I've uploaded the blink test program,so I know that compiling and uploading works and my Arduino Mega works too......

The lcd shield I've got is supposed to be compatible with the Mega2560 but when plugged into the board all I get is a top line of blocks- this suggests to me that the lcd isn initalising properly, probably because the pin assignments are not set correctly...that I think I can sort...

I tend to think of myself as more of a hardware orientated person rather than a software type...

Navigation

[0] Message Index

[#] Next page

Go to full version