Code working on one board but failing on another

Hey y’all,

I buy my Arduino Nanos in packs of 5. These two are from the same group, and I’ve never had a problem until now. Here’s the error code I’m getting:

Arduino: 1.8.13 (Windows 10), Board: "Arduino Nano, ATmega328P"

Sketch uses 5168 bytes (16%) of program storage space. Maximum is 30720 bytes.

Global variables use 242 bytes (11%) of dynamic memory, leaving 1806 bytes for local variables. Maximum is 2048 bytes.

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

avrdude: stk500_getsync() attempt 2 of 10: not in sync: resp=0x4a

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

avrdude: stk500_getsync() attempt 4 of 10: not in sync: resp=0xc0

avrdude: stk500_getsync() attempt 5 of 10: not in sync: resp=0x38

avrdude: stk500_getsync() attempt 6 of 10: not in sync: resp=0x4a

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

avrdude: stk500_getsync() attempt 8 of 10: not in sync: resp=0x27

avrdude: stk500_getsync() attempt 9 of 10: not in sync: resp=0xe9

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

An error occurred while uploading the sketch

I looked around and saw a million different possible solutions, but none that seemed to line up with my situation. This error I am only getting on one board. It occurred while I was troubleshooting a different problem – my LEDs were turning different colors when plugged into a 12V power supply vs. powered by USB. Now I’m worried I might have fried something? Is this error consistent with that?

Last thing – I saw someone saying it could be related to faulty ISR code. I have two interrupts in the code I’m trying to upload, so here is the code too (although I get the same error even when trying to upload Blink). Thanks in advance.

#include <Adafruit_NeoPixel.h>
#define PIN        5
#define NUMPIXELS 80
#define BRIGHTNESS 100
#define inputDT 3
#define inputSW 2
#define inputCLK 4
Adafruit_NeoPixel strip(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

int brightness = BRIGHTNESS;
unsigned long timesincebutt;
int currentStateCLK;
int previousStateCLK;
int counter =0;
String encdir="";

int red = 255;
int green = 255;
int blue = 255;


void setup() {
  // put your setup code here, to run once:
  pinMode(inputSW, INPUT_PULLUP);
  pinMode(inputCLK, INPUT);
  pinMode(inputDT, INPUT);
  Serial.begin(9600); // initialize serial communications at 9600 bps
  attachInterrupt(digitalPinToInterrupt(inputSW), updateButton, LOW);
  attachInterrupt(digitalPinToInterrupt(inputDT), update, CHANGE);


void loop() {
  setStrip(red, green, blue);

//   ISR      ISR      ISR      ISR      ISR      ISR      ISR      ISR      ISR      ISR      ISR      ISR      //

void updateButton(){
  red = 0;
  if(brightness > 250){
    brightness = 10;

void update(){
  // Interrupt to check on the encoder
  currentStateCLK = digitalRead(inputCLK);
  if (currentStateCLK != previousStateCLK){
    if (digitalRead(inputDT) != currentStateCLK){
      // enc would normally be going up, but because of the interrupt pin configuration, up and down are swapped.
      // enc is going down
      //What that thang do
      if(blue > 5){
//        red-=5;
//        green-=5;
      //enc is going up
      //What that thang do
      if (blue<250){
//        green+=5;
//        red+=5;

void setStrip(int red, int green, int blue){
  //Use red, green, and blue to update every pixel in the strip
  for (int i=0;i<NUMPIXELS;i++){
    strip.setPixelColor(i, strip.Color(red, green, blue));

There are quite a few different things that can cause this error, but that is one of them.

If these are the ATmega328P-based “classic” Nanos, I don’t think there is any way it could be related. Due to a deficiency in the old bootloader code, it is possible to “brick” the old official and 3rd party derivative Nano boards with a watchdog timer reset, but that’s the only way I’m aware of to break uploads to one of those boards via the sketch.

Now, in the case of the next generation Nano 33 IoT and Nano 33 BLE boards that have native USB, it is fairly easy for sketch code to break or disable the USB stack that handles the CDC serial port, which prevents uploading, but that’s completely irrelevant for the classic Nano boards, which have a dedicated chip running the USB, which can’t ever be broken by the sketch code.

I order to gather more information that might help us to troubleshoot your problem, I’m going to ask you to post the full output from the upload when in verbose mode.

Please do this:

  1. (In the Arduino IDE) File > Preferences
  2. Uncheck the checkbox next to “Show verbose output during: compilation”/
  3. Check the checkbox next to “Show verbose output during: upload”.
  4. Click the “OK” button.
  5. Attempt an upload, as you did before.
  6. After the upload fails, you’ll see a button on the right side of the orange bar “Copy error messages” (or the icon that looks like two pieces of paper at the top right corner of the black console window in the Arduino Web Editor). Click that button.
  7. In a forum reply here, click on the reply field.
  8. Click the </> button on the forum toolbar. This will add the forum’s ``` code tags markup to your reply.
  9. Press “Ctrl + V”. This will paste the upload output between the code tags.
  10. Move the cursor outside of the code tags before you add any additional text to your reply.

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