Pages: [1]   Go Down
Author Topic: code related uploading problem..  (Read 333 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi All

i have a problem with up loading a sketch to my Mega2560..
this code uploads...
Code:
// 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

« Last Edit: March 13, 2013, 01:12:46 am by dj_lambert » Logged

North Queensland, Australia
Offline Offline
Edison Member
*
Karma: 70
Posts: 2171
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

pYro_65
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...
Logged

North Queensland, Australia
Offline Offline
Edison Member
*
Karma: 70
Posts: 2171
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

pYro_65
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.
Logged

Pages: [1]   Go Up
Jump to: