Hi,
I have a "Graphic ST7565 Positive LCD (128x64) with RGB backlight" from HobbyTronics and a Mega 2560 but I'm having difficulty uploading the sketch. The full sketch uploads on an UNO.
I have added code line by line to try to find where it fails and it appears to be at glcd.clear(); . Here is the cut down code
#include <ST7565.h>
#define BACKLIGHT_LED 10
// pin 9 - Serial data out (SID)
// pin 8 - Serial clock out (SCLK)
// pin 7 - Data/Command select (RS or A0)
// pin 6 - LCD reset (RST)
// pin 5 - LCD chip select (CS)
ST7565 glcd(9, 8, 7, 6, 5);
#define LOGO16_GLCD_HEIGHT 16
#define LOGO16_GLCD_WIDTH 16
//######################bitmaps images large block
static unsigned char __attribute__ ((progmem)) Hbmp[]={
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, };
//######################bitmaps images small block
static unsigned char __attribute__ ((progmem)) Lbmp[]={
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, 0xf8, };
//#####################define sensor pins
int sen1 = 2;
int sen2 = 3;
int sen3 = 4;
int sen4 = A4;
int sen5 = A5;
//#####################define touch screen pins
#define yLow 17
#define yHigh 15
#define xLow 16
#define xHigh 14
const int ymax = 800;
const int ymin = 10;
void setup() {
Serial.begin(9600);
// turn on backlight
pinMode(BACKLIGHT_LED, OUTPUT);
digitalWrite(BACKLIGHT_LED, HIGH);
pinMode(sen1, INPUT);
pinMode(sen2, INPUT);
pinMode(sen3, INPUT);
pinMode(sen4, INPUT);
pinMode(sen5, INPUT);
// initialize and set the contrast to 0x18
glcd.begin(0x18);
[color=red]glcd.clear();[/color]
}
void loop()
{
}
This code compiles OK but when Upload is selected it takes for ever and I receive error messages:
avrdude stk500v2_ReceiveMessage(): timeout
avrdude stk500v2_getsync(): timeout communicating with programmer
I don't understand why it fails to upload with glcd.clear(); to a Mega but uploads and works with an UNO or a Duemilanove.
Any help much appreciated.