Go Down

Topic: code related uploading problem.. (Read 410 times) previous topic - next topic


Mar 13, 2013, 07:10 am Last Edit: Mar 13, 2013, 07:12 am by dj_lambert Reason: 1
Hi All

i have a problem with up loading a sketch to my Mega2560..
this code uploads...
Code: [Select]

// 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() {
 lcd.begin(20, 4);
 // initialize serial communication:
 // initialize the LED pin as an output:
 pinMode(ledPin, OUTPUT);
// display something..
 lcd.setCursor(0, 0);

void loop() {

 // 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
     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);
     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.print("Led is OFF!!");
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


Don't use !!! it is a code captured by the boot loader or some other intermediate process.

Try printing !! then a separate ! to avoid the problem.


Many many thanks....
it works...
so a question is there a list of bootloader capture codes (or have i not read the manual properly)?

thanks again...


Not that I know of, search the forums though. This particular issue has arisen many times, the answer is probably in one of the threads.

Or you could have a scan through the bootloader code.


thanks i will do that.

Hi mellis
i assume the next post was related to my post?
i did check the uploading section of the troubleshooting guide and saw nothing that was related to whether one variation of a sketch uploads and another doesn't, maybe i didn't look hard enough.

Go Up