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
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.
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;
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.