Nano resets during setup()

Hi guys,

I have a simple program that should send a msg to another arduino when something happens.

Worked perfectly for a few weeks, but suddenly it resets during setup().

Here's the code:

/*
  Arduino NANO + NRF24L01
*/

#include <SPI.h>
#include <nRF24L01.h>
#include <RF24.h>
#include <RF24Network.h>


#define CE   9
#define CSN 10

#define SENSOR_1 3


RF24 radio(CE, CSN); // Create a Radio
RF24Network network(radio);
const uint16_t this_node = 02;
const uint16_t master00 = 00;

char dataToSend[4] = "Pos2";
bool jam = false;

int val1 = 0;
int val2 = 0;
int val3 = 0;
int val4 = 0;
int val5 = 0;
int threshold = 150;
int flag = 0;

unsigned long startTime;
unsigned long stopTime;
unsigned long elapsedTime;

unsigned long interval = 5000; // how long in ms should the sensor be active to detect a jam


void setup() {

  Serial.begin(9600);
  Serial.println("Tx Starting");
  SPI.begin();
  radio.begin();
  network.begin(90, this_node);
  radio.setDataRate( RF24_250KBPS );
  radio.setRetries(3, 5); // delay, count

  digitalWrite(SENSOR_1, LOW);                 //change to analog with light barriers
}

//====================

void loop() {

  network.update();
  val1 = digitalRead(SENSOR_1);

  if (val1 == HIGH) {
    jam = true;
  }

  //===== Sending =====//
  if (jam) {   // If a jam is detected, send a message!
    Serial.println("Jam detected");
    RF24NetworkHeader header(master00, '2');   // (Address where the data is going)
    network.write(header, &dataToSend, sizeof(dataToSend)); // Send the data
    Serial.println(dataToSend);
    delay (1000);
    jam = false;
  }
}

The serial monitor just gives me this repeatedly:

Tx St⸮Tx St⸮Tx St⸮Tx St⸮Tx St⸮Tx St⸮

I should mention that I have another Nano with the same code on it, using the same wireless module and it still works perfectly.

Is this Nano fried or am I missing something?

Have you tried to upload a different sketch to the affected Nano?

groundFungus:
Have you tried to upload a different sketch to the affected Nano?

Just tried the digitalReadSerial example.

Got this:

avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00

Changed the usb port on the PC, uploaded successfully, printed 0s and 1s ok, but sometimes there would be a ? after them.

Uploaded my code again, got the same thing in serial monitor again.

I thought it could be a faulty wireless module, but I switched them between the working Nano and this one, same thing happens.

Just a quick update.

Fixed it by disconnecting everything from the Nano and uploading the schetch again. Works fine now.