Programming LCD display(Error compiling for board Mega 2560)

This is my code

#include <LiquidCrystal.h>

LiquidCrystal lcd(1, 2, 4, 5, 6, 7);

void setup() {

void loop(){

  lcd.setCursor (2,1);





And heres the error

Arduino: 1.8.5 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

C:\Users\JackM\AppData\Local\Temp\ccdqBk9b.ltrans0.ltrans.o:(.rodata+0x6): undefined reference to `Print::write(unsigned char const*, unsigned int)'

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/lib/avr6/crtatmega2560.o:(.init9+0x0): undefined reference to `main'

collect2.exe: error: ld returned 1 exit status

exit status 1
Error compiling for board Arduino/Genuino Mega or Mega 2560.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I'm a fair bit of a newbie and i found things similar but not exact as to my problem and i'm not competent enough to work it out on my own yet and didn't want to hijack another thread, so any help would be very much appreciated! so what am i doing wrong?

Try restarting the Arduino IDE to clear the cache.

Thanks Pert i tried doing it a couple of times and it didnt work the first few but now it appears it has worked

Glad to hear! I wish I could give a specific reason why this would happen but I don't know. I've seen this reported several times recently and restarting the IDE does seem to help so it's not caused by a bug in your sketch or the libraries. Something gets messed up with the compiled files that the Arduino IDE caches to speed up compilation. If it comes back you could try doing File > Preferences > Aggressively cache compiled core (uncheck) > OK to see if that will make it go away for good (though this will also cause compilation to be a little slower).

now it appears it has worked

Glad to hear it, but using pin 1 for LCD display is something you might later regret, and you should change it before it becomes habit-forming, or soldered into place. Pins 0,1 are for serial connection.