Pages: [1]   Go Down
Author Topic: Leonardo Question  (Read 737 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 59
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 202
Posts: 8716
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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?"

Logged

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

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6137
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Schematic?
Logged

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

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 59
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:


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

0
Offline Offline
God Member
*****
Karma: 0
Posts: 594
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Modify the bootloader, or use an ISP programmer for all future programming.
Logged

Freelance engineer, consultant, contractor. Graduated from UW in 2013.

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 59
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 59
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

0
Offline Offline
Jr. Member
**
Karma: 1
Posts: 59
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Full Member
***
Karma: 0
Posts: 115
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Offline Offline
Full Member
***
Karma: 0
Posts: 115
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Austin, TX
Offline Offline
Faraday Member
**
Karma: 71
Posts: 6137
Baldengineer
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Pages: [1]   Go Up
Jump to: