Trouble uploading code to Arduino Nano Every Board

Hi everyone,
So I am attempting to create a room occupancy monitor, using two motion sensors and an arduino nano-every (ATMEGA4809). I then want to send the occupancy of the room as an integer to Max MSP through serial.
I'm somewhat new to this and am having trouble uploading my code to the board. The code compiles no problem (although I'm sure its littered with errors I hope to troubleshoot later), but gives the following error message when uploading: "avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 1 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 3 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 7 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0x00
avrdude: stk500_recv(): programmer is not responding
avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x00
Problem uploading to board. See https://support.arduino.cc/hc/en-us/sections/360003198300 for suggestions."

I've attached my code below.
Any help regarding any of this would be wonderful.
Thank you,
Kieran

int maxPeople = 5; // maximum number of people allowed before the alarm goes off
int sensitivity = 5; //lower values will make it more sensitive and higher values will make it less sensitive
//---------------------------------------------------


int currentPeople = 0;


int sensor1[] = {4,5};
int sensor2[] = {6,7};
int sensor1Initial;
int sensor2Initial;

String sequence = "";

int timeoutCounter = 0;

void setup() {
  //Setup code
  Serial.begin(9600);

  delay(500);
  sensor1Initial = measureDistance(sensor1);
  sensor2Initial = measureDistance(sensor2);
}

void loop() {
  //Read ultrasonic sensors
  int sensor1Val = measureDistance(sensor1);
  int sensor2Val = measureDistance(sensor2);
  
  //Process the data
  if(sensor1Val < sensor1Initial - 30 && sequence.charAt(0) != '1'){
    sequence += "1";
  }else if(sensor2Val < sensor2Initial - 30 && sequence.charAt(0) != '2'){
    sequence += "2";
  }
  
  if(sequence.equals("12")){
    currentPeople++;  
    sequence="";
    delay(550);
  }else if(sequence.equals("21") && currentPeople > 0){
    currentPeople--;  
    sequence="";
    delay(550);
  }

  //Resets the sequence if it is invalid or timeouts
  if(sequence.length() > 2 || sequence.equals("11") || sequence.equals("22") || timeoutCounter > 200){
    sequence="";  
  }

  if(sequence.length() == 1){ //
    timeoutCounter++;
  }else{
    timeoutCounter=0;
  }

  //Print values to serial
  Serial.print("Seq: ");
  Serial.print(sequence);
  Serial.print(" S1: ");
  Serial.print(sensor1Val);
  Serial.print(" S2: ");
  Serial.println(sensor2Val);
  
  

  /*If the number of people is too high, trigger the buzzer
  if(currentPeople > maxPeople){
    tone(buzzer, 1700);  
  }else{
    noTone(buzzer);  
  }
  */
}

//Returns the distance of the ultrasonic sensor that is passed in
//a[0] = echo, a[1] = trig
int measureDistance(int a[]) {
  pinMode(a[1], OUTPUT);
  digitalWrite(a[1], LOW);
  delayMicroseconds(2);
  digitalWrite(a[1], HIGH);
  delayMicroseconds(10);
  digitalWrite(a[1], LOW);
  pinMode(a[0], INPUT);
  long duration = pulseIn(a[0], HIGH, 100000);
  return duration / 29 / 2;


  Serial.println(currentPeople);
}

Have you selected the correct port in the IDE ? Is it available. Easiest is to unplug the board, check which ports are available. plug it in again and then it should show up.
what do you have selected as a board ?

I was new (and still am), used an Uno and hat the error code 0x44. So slightly different situation to me: Failed to upload: avrdude: stk500_getsync() attempt 10 of 10: not in sync: resp=0x44

However, consider to have a broken Arduino, or a least a broken bootloader.
I was recommended to connect pin0 and pin1 (RX and TX); directly with a jumper wire, no resistor and such.
When I opened the serial monitor, I should see everything I type directly as a response.
This worked, which was an indicator for a broken bootloader. I replaced the Arduino in the shop (and bought an additional one) and both worked out of the box.

I could also have a look at https://support.arduino.cc/hc/en-us/sections/360003198300 and https://support.arduino.cc/hc/en-us/articles/4401874331410.

I hope that helps.

I had selected the correct port (/dev/cu.usbmodem14101), and i had arduino nano selected as board, Thanks!

It seems the loopback test has failed. After following the instructions the serial monitor did not yield the results I HAD hoped for. It seems I will have to replace my board.
Thanks for all your help!!!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.