I have one of those Chinese boards and it in general does what I tell it to do.
But I seem unable to control the two LEDs!
They both flash back and forth during setup. I have an external LED going on during Setup, and the flashes continue after that.
I have tried to control D14 directly (Rx LED apparently), but the LED does not do, what I want it to.
I have tried using direct port access for PD5 (Tx LED), but with same result. This LED is visually connected to chip pin 22 (PD5)
DDRD = B00100000; (code found elsewhere here on forum)
The project starts mouse operations at the end of the setup process. Does that change things?
Mouse.move does seem to turn Tx LED on!
As it is at the moment both LED end up turned ON when the Loop process starts. Even if I in Setup set D14 as input!
Is it documented which pins are fully available during mouse operations and which are not?
The pins are defined, but you need the newest Arduino IDE.
The leds are not connected to GND but to 5V. A LOW will turn it on.
They are already initialized as output pins, and turning them into input pins did work for me to turn them off.
It is not perfect, but I use this:
// Turn on (true) or off (false) the Tx and Rx led.
// They are turned off by making them input.
// That prevents that any RX or TX activity will turn them on.
// However, when the leds are on, any RX or TX action will
// make them blink or turn them off.
void ledTx( boolean on)
// led on. The led is connected to VCC. Make pin low to turn led on.
pinMode( LED_BUILTIN_TX, OUTPUT); // pin as output.
digitalWrite( LED_BUILTIN_TX, LOW); // pin low
// These two lines will do the same:
// bitSet( DDRD, 5);
// bitClear( PORTD, 5);
// led off
// turn it off, by setting it as input, so the serial activity can't turn it on.
// If the internal pullup resistor is enabled or not, that does not matter,
// since the led it connected to VCC.
pinMode( LED_BUILTIN_TX, INPUT);
// This line will do the same:
// bitClear( DDRD, 5); // set pin as input
void ledRx( boolean on)
pinMode( LED_BUILTIN_RX, OUTPUT);
digitalWrite( LED_BUILTIN_RX, LOW);
// bitSet( DDRB, 0);
// bitClear( PORTB, 0);
pinMode( LED_BUILTIN_RX, INPUT);
// bitClear( DDRB, 0);
At the end of setup(), I do this:
// initialize both leds to be off
My understanding is that you can directly control the TX LED through the macro: TXLED0 (turns it off) and TXLED1 turns it on. You can use the same for RXLED... RXLED0, RXLED1. However, the RXLED can be directly accessed on Pin 17. The "Blinkies" sketch at the SparkFun website shows how to control them.