In order to communicate serially, the Pro Micro emulates a virtual serial port. This begs the age-old question: "If a Pro Micro is saying 'Hello!' over the hardware serial port, and nothing is there to hear it, does the Pro Micro really say anything at all?" Why Does My Board Re-Enumerate Every Upload? ' Hello! Can anybody hear me?' is being sent out over the hardware UART, where, presumably, nothing is listening. If you open up the Serial Monitor, you should only see Hello world! printed. The Serial1 port is a bonafide, hardware UART, where your Pro Micro can talk to any serial-enabled piece of hardware. The one without the " 1" is for communication to and from the computer over USB this is what is visible in the Serial Monitor. Think of the Pro Micro having two separate serial ports. In that sketch, you'll also notice a pair of Serial initialization statements: language:c Serial Monitor ( Serial) and Hardware Serial UART ( Serial1) TXLED1 turns the LED on, and TXLED0 turns the LED off. The TX LED was not provided as an Arduino-defined pin, unfortunately, so you'll have to use a pair of macros to control it. Set it as an OUTPUT, and digitalWrite(, ) it HIGH to turn the LED off or LOW to turn the LED on. You can control it just as you would any other digital pin. You can also open up the Arduino IDE's serial monitor (set to 9600 bps) and see every programmer's favorite two-word phrase. With the code uploaded you should see the RX and TX LEDs take turns blinking on and off every second. TXLED0 //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFFĭigitalWrite(RXLED, HIGH) // set the RX LED OFF Serial1.println("Hello! Can anybody hear me?") // Print "Hello!" over hardware UARTĭigitalWrite(RXLED, LOW) // set the RX LED ON Serial.println("Hello world!") // Print "Hello World" to the Serial Monitor Serial1.println("Initialize Serial Hardware UART Pins") Serial1.begin(9600) //This is the UART, pipes to sensors attached to board Serial.println("Initialize Serial Monitor") Serial.begin(9600) //This pipes to the serial monitor TX LED is set as an output behind the scenes PinMode(RXLED, OUTPUT) // Set RX LED as an output (We could use the same macros for the RX LED too - RXLED1, ![]() macros (TXLED1, TXLED0) to control that. Note: The TX LED was not so lucky, we'll need to use pre-defined ![]() Int RXLED = 17 // The RX LED has a defined Arduino pin To explain the difference between Serial.print() and ProMicro's TX and RX LEDs within a sketch. This code is provided to show how to control the SparkFun License: Public Domain - please use this code however you'd like. Finally, upload it to your Pro Micro language:c Make sure to select the correct board and COM port that your respective board enumerated to. So let's get blinking! Upload the RX/TX Blinky, Hello World SketchĬopy and paste the code below into the Arduino IDE. Unlike other Arduino boards, though, we can control the RX/TX LEDs in our sketch. In fact, the only LEDs on the board are the power indicator, and RX/TX blinkies. The Arduino-standard Blink sketch won't have any visible effect on the Pro Micro - there's no LED on pin 13. Share on Twitter Share on Facebook Pin It Example 1: Blinkies!
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |