1

I am looking to utilize Pin 13 and an external LED to flicker as either the Rx or Tx LEDs do when Serial data is transferred through the Arduino. The existing code is all in real time to function with external buttons, so there can't be any delay.

I came across this link which seems useful, but I can't quite get it to read from Serial:

http://arduino.cc/en/Tutorial/BlinkWithoutDelay

Thanks in Advance

  • 2
    Software fundamentally does not do things without one or more clock cycles of delay, and the ATmega is not an FPGA which allows you to route signals to desired pins electrically. If you want exactly the same data without delay, then don't use pin 13, but rather use the Tx or Rx pin. If you merely want similar functionality, then either use a software serial on the pin to which your LED is connected, or write a custom Serial output routine which twiddles an LED pin every time it writes a character to the UART peripheral or services the UART Rx interrupt. – Chris Stratton Jan 17 '15 at 16:54
  • when you say "there can't be any delay" you are referring to the use of delay(ms); and other blocking code, and not "must happen the exact same moment" correct? – BrettAM Jan 17 '15 at 23:13
  • I think that pins 0/1 should blink similar to the TX/RX LEDs but not entirely sure. Might be worth it to see if that works and then let us know. – Anonymous Penguin Jan 18 '15 at 17:11
  • BrettM, your are assuming correct. When i connect and LED to 0 or 1, it's constantly lit, no change with data transfer, even though data is indeed flowing. – Scott K Jan 18 '15 at 17:13
1

If you are going to use an external LED, then using software to make the LED blink when the RX or TX line is busy is a waste of your CPU.

Instead, simply connect the LED to the RX or TX line using a transistor as a buffer to prevent the current draw from messing with the serial signal.

To borrow an image from this answer to a similar question:

enter image description here

You can try omitting the transistor buffer, but the serial waveform will be altered, possibly to the point where data becomes corrupted. The transistor prevents the current draw of the LED and resistor from loading down the RX or TX lines.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.