Go Down

Topic: Leonardo Question (Read 901 times) previous topic - next topic

jeffd

For simplicity, I made a video to ask my question:

http://www.youtube.com/watch?v=nXldtGzONus&feature=youtu.be

johnwasser

The question in the video is:

"LEDs are connected to most of the Arduino Leonardo pins. When I power up or reset some of the LEDs pulse for a few seconds (reportedly something the bootloader does).  Can I get rid of that and have it go straight to my sketch?  If so, how?"

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

James C4S

Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

jeffd

Sorry, I thought posting a video would help facilitate the process, guess not. Thanks for posting the summary though, I really need to figure this out. I don't have a schematic but its really simple, just LEDS connected to pwm pins that fade on in succession. Here is the code I'm using:

Code: [Select]



int leds[] = {
  3,5,6,9,10,11,13};
int num = 7;


void init_leds(){
  for(int i = 0; i<num; i++){
    digitalWrite(leds[i],LOW);
    pinMode(leds[i], OUTPUT);     
  }
}

void FadeOutLeds(){
  for(int i = 155;i>0;i--){

    for(int j = 0;j<num;j++){
      analogWrite(leds[j],i);
    }
    delay(80);
  }

}

void FadeInLed(int theLed){
  for(int i = 0;i<256;i++){
    analogWrite(theLed,i);
    delay(20);
  }
}


void setup() {               
  // initialize the digital pins as an output.
  init_leds();
}

// the loop routine runs over and over again forever:
void loop() {

  for(int i = 0; i<num;i++){
    FadeInLed(leds[i]);     
  }
  delay(5000);               // wait for 5 seconds
  FadeOutLeds();
  delay(5000); 
}



Im not certain a schematic would help anyway. Im not sure theres technically anything wrong, from what I've read about the Leonardo the bootloader takes 8 seconds to run which is exactly how long the first LEDs pulse for. I just need to know if theres a way to make them stop and have my project begin right away vs. having to wait 8 seconds before the above code is executed.

frank26080115

Modify the bootloader, or use an ISP programmer for all future programming.
Freelance engineer, consultant, contractor. Graduated from UW in 2013.

jeffd

Could you maybe explain that a little more? I'm a beginner. Is there a way I can accomplish that without any extra hardware?

jeffd

Ah ha! After a little digging, I've found this:

Quote
When you upload a sketch, you're using the Arduino bootloader, a small program that has been loaded on to the microcontroller on your board. It allows you to upload code without using any additional hardware. The bootloader is active for a few seconds when the board resets; then it starts whichever sketch was most recently uploaded to the microcontroller. The bootloader will blink the on-board (pin 13) LED when it starts (i.e. when the board resets).


That explains the pulsing LED in the beginning. Im still not sure how to ditch the bootloader though...

jeffd

Making some progress here... for what I've read I can use another Arduino to burn the bootloader using ISP, but in order to upload a sketch and overwrite the bootloader I would need to use an ICSP programmer. Is that correct? If I can use another Arduino to burn the bootloader can I also use it to burn a modified bootloader?

silasmoeckel


Ah ha! After a little digging, I've found this:

Quote
When you upload a sketch, you're using the Arduino bootloader, a small program that has been loaded on to the microcontroller on your board. It allows you to upload code without using any additional hardware. The bootloader is active for a few seconds when the board resets; then it starts whichever sketch was most recently uploaded to the microcontroller. The bootloader will blink the on-board (pin 13) LED when it starts (i.e. when the board resets).


That explains the pulsing LED in the beginning. Im still not sure how to ditch the bootloader though...


If you program it with another arduino or similar ISP based programmer there is no bootloader thus no blinking.  The downside is you will have to continue to use them until you put the boot loader back with one.  If you do not have or do not want to use another arduio a standalone programmer is a few bucks on ebay.  Personally I use a hacked version of the ebay one to also give me ttl serial have yet to find anybody selling those.

silasmoeckel


Making some progress here... for what I've read I can use another Arduino to burn the bootloader using ISP, but in order to upload a sketch and overwrite the bootloader I would need to use an ICSP programmer. Is that correct? If I can use another Arduino to burn the bootloader can I also use it to burn a modified bootloader?


ISP and ISCP are pretty much interchangeable.  If you can burn the boot loader you can burn a sketch there really is no difference.

James C4S


I don't have a schematic but its really simple, just LEDS connected to pwm pins that fade on in succession.

With current limiting resistors, right?  Otherwise, you'll be buying new Leonards soon.
Capacitor Expert By Day, Enginerd by night.  ||  Personal Blog: www.baldengineer.com  || Electronics Tutorials for Beginners:  www.addohms.com

Go Up