Get Blink to work properly-Generic Pro Mirco, acts as Leonardo

Hello, first post~
I had part of the same issue as the user in this thread- Pro Micro (Leonardo?) Help with blink test - Programming Questions - Arduino Forum.
The OP posted, "I was able to find a reference to a pin 17 to modify the Blink example and uploaded it successfully, as the one small onboard LED started to blink."
How does one do this?
I am a baby noob- I started building li'l fm radios in December, and just started learning about microcontrollers in January, so I'm fumbling around, learning what I can here and there, without any foundation but interest.
If anyone could point me in the right direction, I'd much appreciate it. :slightly_smiling_face:

mriden:
The OP posted, "I was able to find a reference to a pin 17 to modify the Blink example and uploaded it successfully, as the one small onboard LED started to blink."
How does one do this?

Here's the Blink example:

void setup() {
  // initialize digital pin LED_BUILTIN as an output.
  pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

In this code, the name LED_BUILTIN is used as pinMode() and digitalWrite()'s pin number argument. LED_BUILTIN is just s convenient name set to the pin number the built in LED is connected to on boards that have one. For example, on the Uno its value is 13 because the Uno's built in LED is connected to pin 13.

So if your LED is on pin 17, then you only need to replace all the ocurrences of "LED_BUILTIN" in the sketch with the number 17.

Similar to LED_BUILTIN, there is a convenient name for this pin as well: LED_BUILTIN_RX
So if you like, you can use LED_BUILTIN_RX instead of 17. The reason for the "RX" part of the name is that this pin is actually used to indicate data being received from the computer over the Serial data connection ("RX" stands for "receive"). But you are also able to control it from your sketch code however you like. Just don't be surprised if you find it blinking when you are sending serial data (e.g., uploading or using Serial Monitor). Similarly, there is another LED on the pin named LED_BUILTIN_TX (pin 30) to indicate when data is being transmitted from the Arduino board to the computer over Serial (e.g., when you're using Serial.println() to send print data to Serial Monitor). You can also use that pin from your sketch if you like.

References:

Open up the Arduino IDE and from the menu select FIle > Examples > 01.Basic > Blink

Be sure to select the correct Arduino board and programmer under the Tools menu.

The 'official' SparkFun example

Ya know, I could have sworn I tried this, but I must have missed something, because it worked when I copy/pasted it. Thank you much!

EDIT: I thought about it- I probably tried the sketch before I had the com ports straightened out... was having some trouble with that at first.

pert:
Here's the Blink example:

void setup() {

// initialize digital pin LED_BUILTIN as an output.
 pinMode(LED_BUILTIN, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
 digitalWrite(LED_BUILTIN, HIGH);   // turn the LED on (HIGH is the voltage level)
 delay(1000);                       // wait for a second
 digitalWrite(LED_BUILTIN, LOW);    // turn the LED off by making the voltage LOW
 delay(1000);                       // wait for a second
}



In this code, the name LED_BUILTIN is used as pinMode() and digitalWrite()'s pin number argument. LED_BUILTIN is just s convenient name set to the pin number the built in LED is connected to on boards that have one. For example, on the Uno its value is 13 because the Uno's built in LED is connected to pin 13.

So if your LED is on pin 17, then you only need to replace all the ocurrences of "LED_BUILTIN" in the sketch with the number 17.

Both versions worked perfectly!! This was exactly the bit I was wondering about- which part to replace. I had some understanding that I needed to replace 13 with 17 somewhere, but sparkfun didn't do a 1/1 example- they used RXLED and, I just figured out, int RXLED = 17... I swear I couldn't get their example to work the first time... oh well.

int RXLED = 17; 

void setup()
{
  pinMode(RXLED, OUTPUT);
}

// the loop function runs over and over again forever
void loop() {
  digitalWrite(RXLED, HIGH);   // turn the LED on (HIGH is the voltage level)
  delay(1000);                       // wait for a second
  digitalWrite(RXLED, LOW);    // turn the LED off by making the voltage LOW
  delay(1000);                       // wait for a second
}

(I mushed the codes together successfully!) ... it hadn't occurred to me to replace the words with a number- thank you so much, this is excellent, it opens up a lot! :smiley_cat:

jremington:
Open up the Arduino IDE and from the menu select FIle > Examples > 01.Basic > Blink

Be sure to select the correct Arduino board and programmer under the Tools menu.

I appreciate the thought. I'd gotten a couple other easier boards before I decided to try the pro micro- all mega328 or 2560- and I hadn't had trouble with those. The computer was reading it as a Leonardo, the leds said it was receiving the sketch, but the led would blink once and stop, like the OP of the other post wrote. The original code uses pin 13, my board needed it to use 17, didn't know how to switch it. Some other lovely folks told me.

mriden:
thank you so much, this is excellent, it opens up a lot! :smiley_cat:

You're welcome. I'm glad to hear it's working now. Enjoy!
Per

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.