EasyManua.ls Logo

sparkfun Qwiic Pro Micro USB-C - Page 23

sparkfun Qwiic Pro Micro USB-C
45 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
You can also open up the Arduino IDE's serial monitor (set to 9600 bps) and see every programmer's favorite two-
word phrase.
Understanding the Sketch
RX LED
The RX LED is tied to Arduino's pin 17. You can control it just as you would any other digital pin. Set it as an
OUTPUT , and digitalWrite([pin], [level]) it HIGH to turn the LED off or LOW to turn the LED on. Here's part
of the code highlighted.
int RXLED = 17; // The RX LED has a defined Arduino pin
void setup(){
pinMode(RXLED, OUTPUT); // Set RX LED as an output
}
.
.
.
digitalWrite(RXLED, LOW); // set the RX LED ON
digitalWrite(RXLED, HIGH); // set the RX LED OFF
TX LED
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. TXLED1 turns the LED on, and TXLED0 turns the LED off. We could use the same macros for the RX
LED too -- RXLED1 and RXLED0 . Here's part of the code highlighted.
TXLED0; //TX LED is not tied to a normally controlled pin so a macro is needed, turn LED OFF
TXLED1; //TX LED macro to turn LED ON
Serial Monitor ( Serial ) vs Hardware Serial UART ( Serial1 )
In that sketch, you'll also notice a pair of Serial initialization statements: