Code doesn't upload to arduino nano every

i am working on an iron man helmet from box and loop, but when i try to upload the code to my arduino nano every, it doesn't work. This is the code that was provided, someone please help

#include "ServoEasing.h"
ServoEasing servoTop;
ServoEasing servoBottom;
const int action_pin = 2;
int location = 31;
// Below numbers should be adjusted in case the facemask does not close/open to desired angle
int bottom_closed = 107;
int top_closed = 167;
int bottom_open = 20;
int top_open = 20;
void setup()
{
 pinMode(action_pin, INPUT_PULLUP);
 servoTop.attach(9);
 servoBottom.attach(10);
 setSpeedForAllServos(190);
 servoTop.setEasingType(EASE_CUBIC_IN_OUT);
 servoBottom.setEasingType(EASE_CUBIC_IN_OUT);
 synchronizeAllServosStartAndWaitForAllServosToStop();
}
void loop()
{
 int proximity = digitalRead(action_pin);
 if (proximity == LOW)
 {
 if (location > bottom_open) {
 servoTop.setEaseTo(top_open);
 servoBottom.setEaseTo(bottom_open);
 synchronizeAllServosStartAndWaitForAllServosToStop();
 location = bottom_open;
 delay(600);
 } else {
 servoTop.setEaseTo(top_closed);
 servoBottom.setEaseTo(bottom_closed);
 synchronizeAllServosStartAndWaitForAllServosToStop();
 location = bottom_closed;
 delay(600);
 }
 }
}

this is the error message i'm getting:

Sketch uses 7784 bytes (15%) of program storage space. Maximum is 49152 bytes.
Global variables use 170 bytes (2%) of dynamic memory, leaving 5974 bytes for local variables. Maximum is 6144 bytes.
avrdude: jtagmkII_initialize(): Cannot locate "flash" and "boot" memories in description
avrdude: jtagmkII_reset(): timeout/error communicating with programmer (status -1)
avrdude: initialization failed, rc=-1
         Double check connections and try again, or use -F to override
         this check.

avrdude: jtagmkII_close(): timeout/error communicating with programmer (status -1)
avrdude: jtagmkII_close(): timeout/error communicating with programmer (status -1)
Failed uploading: uploading error: exit status 1

this is my first time using arduinos and i have had a lot of problems with it, some i could fix with the help of other topics, but this one i dont know what i have to do.

I could not duplicate your error. I verified and uploaded your code to a Nano Every using IDE v2.3.2 and ServoEasing library v3.5.0, this one:

I did receive a warning and failure to compile upon first attempt; however, it wasn't the same error as yours. The error I received indicated that the library you are using needs to be called with a .hpp file, not a .h, which is explained at the library link above.

So

should be

#include "ServoEasing.hpp"

As for your error, are you sure you installed the Nano Every boards package in your IDE?
Under Tools > Board > Boards Manager start typing Nano Every in the search box and "Arduino megaAVR Boards by Arduino" should pop up. Make sure it's installed.

The version I have of that is 1.8.8

Install it if not there and I always like to restart the IDE after installing libraries and boards because reasons. Don't know if that's strictly necessary, but I do it anyway.

i did everything you said, but i still get the same error message.
Is there a chance it could be because i already have something soldered to my board? Or because i already have something programmed on my board? Because i don't know how to fix that, but maybe that could be the problem

Distinct possibility depending on which pins you have connected?

Usually the new program would just overwrite the old one.

No, the new sketch should overwrite it no problem.

Could be, what pins do you have things soldered to?

Have you tried using the old bootloader (under processor) I am unfamiliar with the nano every but I’ve had the same issue with just a classic nano where you need to select the old bootloader. I’m not sure if it will work but might be worth a shot.

Issue in Your Code Fix Applied

Missing <ServoEasing.hpp> correct include Fixed
Using location int but comparing to angle (bad logic) Replaced with boolean helmetOpen
No debouncing → false triggers Added 600ms delay after toggle
Code wasn’t structured for clear open/close logic Now clean & readable
Start could cause sudden jerk Added sync stop at startup

Wiring Reminder

Arduino Pin Device

D9 Top servo signal
D10 Bottom servo signal
D2 Trigger/Proximity switch/input
5V Servos VCC (or external 5–6V supply recommended)
GND Common ground with servos & Arduino

Use external power if your servos are metal gear or high torque!
Do NOT power both servos from Arduino 5V.

Use this code to upload

''' #include <ServoEasing.hpp>

ServoEasing servoTop;
ServoEasing servoBottom;

const int action_pin = 2;
bool helmetOpen = false; // Tracks current state (open/close)

// Adjust these values to fit your servo angles
int bottom_closed = 107;
int top_closed = 167;
int bottom_open = 20;
int top_open = 20;

void setup() {
pinMode(action_pin, INPUT_PULLUP);

servoTop.attach(9);
servoBottom.attach(10);

// Servo speed & easing
setSpeedForAllServos(190); // 0-255 → 190 is smooth & realistic
servoTop.setEasingType(EASE_CUBIC_IN_OUT);
servoBottom.setEasingType(EASE_CUBIC_IN_OUT);

// Ensure no movement happens at startup glitch
synchronizeAllServosStartAndWaitForAllServosToStop();
}

void loop() {
int proximity = digitalRead(action_pin);

if (proximity == LOW) {
if (helmetOpen == false) {
// OPEN VISOR
servoTop.setEaseTo(top_open);
servoBottom.setEaseTo(bottom_open);
synchronizeAllServosStartAndWaitForAllServosToStop();
helmetOpen = true;
delay(600);

} else {
  // CLOSE VISOR
  servoTop.setEaseTo(top_closed);
  servoBottom.setEaseTo(bottom_closed);
  synchronizeAllServosStartAndWaitForAllServosToStop();
  helmetOpen = false;
  delay(600);
}

}
} '''

That's not applicable to a Nano Every; the processor options are not even there when the Nano Every is selected.

This is what i soldered, does it matter if i did this?

Yeah, but I never coded something and I got this code from a youtuber. But I can try your code if you think it Will work. Thanks for leaving a reaction.

i'm getting the same error message with this code, but thanks for the reply

Did you try to upload Blink (File > Examples > Basics > Blink)?
If this doesn't upload either the problem isn't the program.

In the Nano Every you need to watch out for Compatibility Mode (Tools > Registers emulation > None)

That also does’t work

If i Flick the switch, the board does power on, which I can see because of the on-board light. But when I push the button, it does’t turn the servo’s

I do not know if this was asked.

What is the power source? 4x AA batteries? If so, the documentation for the Nano Every states that the minimum Vin is 7V.

This was asked of you previously. What is your answer?

Does that program load and run?

Have you tried using it with fresh batteries in your battery box, as well as having the Nano Every connected to your USB port on your PC?

Try running this version of your code. I added Serial debugging so we can at least get more info:

#include "ServoEasing.hpp"
ServoEasing servoTop;
ServoEasing servoBottom;
const int action_pin = 2;
int location = 31;
// Below numbers should be adjusted in case the facemask does not close/open to desired angle
int bottom_closed = 107;
int top_closed = 167;
int bottom_open = 20;
int top_open = 20;
void setup() {
  Serial.begin(9600);
  Serial.println("Iron Man Mask");
  delay(1000);
  pinMode(action_pin, INPUT_PULLUP);
  servoTop.attach(9);
  servoBottom.attach(10);
  setSpeedForAllServos(190);
  servoTop.setEasingType(EASE_CUBIC_IN_OUT);
  servoBottom.setEasingType(EASE_CUBIC_IN_OUT);
  synchronizeAllServosStartAndWaitForAllServosToStop();
}
void loop() {
  int proximity = digitalRead(action_pin);
  if (proximity == LOW) {
    if (location > bottom_open) {
      servoTop.setEaseTo(top_open);
      servoBottom.setEaseTo(bottom_open);
      synchronizeAllServosStartAndWaitForAllServosToStop();
      location = bottom_open;
      Serial.println("bottom open");
      delay(600);
    } else {
      servoTop.setEaseTo(top_closed);
      servoBottom.setEaseTo(bottom_closed);
      synchronizeAllServosStartAndWaitForAllServosToStop();
      location = bottom_closed;
      Serial.println("bottom closed");
      delay(600);
    }
  }
}

compiled with library v3.5.0, this one:

using IDE v2.3.2

It's possible your board has died. The info you found didn't warn you for this:

This may destroy the 5V regulator.

I already answered it, but it didn’t work