Hi All
i have a problem with up loading a sketch to my Mega2560..
this code uploads...
// include the library code:
#include <LiquidCrystal.h>
const int ledPin = 13; // the pin that the LED is attached to
int incomingByte; // a variable to read incoming serial data into
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
void setup() {
delay(1000);
lcd.begin(20, 4);
delay(1000);
// initialize serial communication:
Serial.begin(9600);
// initialize the LED pin as an output:
pinMode(ledPin, OUTPUT);
// display something..
lcd.setCursor(0, 0);
lcd.print("Hello");
delay(1500);
}
void loop() {
lcd.clear();
// see if there's incoming serial data:
if (Serial.available() > 0) {
// read the oldest byte in the serial buffer:
incomingByte = Serial.read();
// if it's a capital H (ASCII 72), turn on the LED:
if (incomingByte == 'H') {
digitalWrite(ledPin, HIGH);
// Display LED state
//SetDisp();
lcd.setCursor(0, 0);
//lcd.print("Led is ON!!!"); // commented uploads ok, un-commented doesn't upload
}
// if it's an L (ASCII 76) turn off the LED:
if (incomingByte == 'L') {
digitalWrite(ledPin, LOW);
//SetDisp();
lcd.setCursor(0, 0);
//lcd.print("Led is OFF!!!"); // commented uploads ok, un-commented doesn't upload
}
}
}
// separate sub as a test
/*void SetDisp(){
if (digitalRead(ledPin == LOW)){
lcd.setCursor(0,0);
lcd.print("Led is OFF!!");
}
else{
lcd.print("Led is ON!!!");
}
}*/
if i un-comment either of the lcd.print statements or try to use the separate sub SetDisp the upload starts and then eventually times out i am uploading over the inbuilt usb.
i have tried it on 2 different computers and both versions of current Arduino software..
i am sure i must be doing something stupid but cannot see it..
thanks in advance