ATMEGA resets c program when starting and stopping reading data from a PC
Am I to understand that you are not using the Arduino IDE's Serial Monitor to display your data? In which case I would have to assume that you're using another IDE or program, or you're building your own software to interface with your Arduino ATMEGA328 hardware. I'm not sure I understand. Can you be more precise? Which program are you using as the &quot;receiving program&quot; if it's not the Arduino IDE?
It sounds like you're using a loop structure to increment a (4-digit) line number as your computer receives the data. The Arduino UNO, Nano, and MEGA2560 use the ATMEGA328 if I'm not mistaken. I know for fact the UNO uses digital pins 0 and 1 to send and receive data. I don't know if you have anything connected to these pins that could be causing a problem, but it is normal for the RX and TX LEDs to flicker as data is being sent or transmitted (TX), and when data is being received (RX). On the MEGA2560, communication pins are used for transmitting and receiving data on pins 14-19 (TX1, RX1, TX2, RX2, TX3, and RX3). The LEDs work the same as on the UNO, and should flicker when the board sends or receives data. With what little info you gave, I suspect that you have a coding problem, but without any code I can not verify this. However, I strongly believe that your board is working properly. However, these pins should not affect your counter. If you have anything connected to RX or TX on any of the three microcontroller boards, try connecting these to other digital pins, and see if this solves the problem. Don't forget to change your code to include the new pins.