Precise conditions when RX/TX leds turn on?


I noticed today that the RX led on my UNO turns on, even though (a) I am not sending data from the computer (that I know of) and (b) no data appears to be arriving at the atmega328p rx register.

I would like to know what exactly the conditions are that turn on the rx led - why might it turn on without having received data?


Can you post your code . So we can understand the problem.

Have you uploaded program with serial out code.

The TX and RX LEDs are controlled by the USB drivers on your computer. So if they are on when you think they should not be then it is the driver software that is doing it.

On the computer side (linux), all I am doing is

cat /dev/ttyACM0

On the arduino, I’m using a serial library, which can be downloaded here:

As for my program, it has two timers: one is clocked from the system clock, the other from external clock T1 (which is connected to a flow meter). The ISR updates the count every time timer0 overflows, and the main loop sends the new value to the computer (in hex) every time it sees a new value. I see the Rx led flash every time the Tx led flashes. Notably, that didn’t happen in an earlier version that didn’t have any code to handle Rx functionality (the uart library above handles both rx and tx using interrupts). Here’s the code:

#include <avr/io.h>
#include <avr/interrupt.h>

#include "uart.h"

#define FOSC 16000000
#define BAUD 115200
#define MYUBRR (FOSC/8/BAUD-1) | 0x8000 /* top bit set for double speed */

uint16_t count = 0;
unsigned char i_timer = 0;
unsigned char n_timer = 0;

ISR( TIMER0_OVF_vect )
 asm("cli"); /* Disable interrupts */
  count = TCNT1;
 asm("sei"); /* Enable interrupts */

int main (void)
 unsigned char n_send = 0;
 char out[8] = { '0', 'x', 0,0,0,0,'\n',0};
 char i;

 /* set pin 5 of PORTB for output*/
 DDRB = (1 << DDB5);
 DDRD = 0;

 /* Timer 0 settings */
 TCCR0A = 0x00;
 TCCR0B = 0x05; /* Prescaler / 1024 */
 TCNT0 = 0x00;
 TIMSK0 = 0x01; /* Enable interrupt on TCNT0 overflow */

 /* Timer 1 settings */
 TCCR1A = 0x00;
 TCCR1B = 0x87;
 TCNT1 = 0x0000;


 asm("sei"); /* Enable interrupts */

 while(1) {
  if(n_timer == n_send) {
   asm("cli"); /* Disable interrupts */
   n_send = n_timer + 1;
   asm("sei"); /* Enable interrupts */

   if (uart_available()) {
    PORTB |= 1<<PB5;
   } else {
    PORTB &= ~(1<<PB5);

   out[5] = (count & 0xf);
   out[4] = (count >> 4) & 0xf;
   out[3] = (count >> 8) & 0xf;
   out[2] = (count >> 12) & 0xf;

   for( i = 2; i<6; i++) {
     out[i] += (out[i] < 10) ? '0' : 'A' - 10;
  } else {


 return 0;

Also note that this isn't a "problem" per se - the program functions as desired. I'd just like to know exactly what is happening for the sake of understanding (and saving power etc. by reducing functionality).