Cannot find port when uploading sketch to board (UNO)

I have a sketch that uses the fastLED libary. I am trying to set all the LEDs in a certain patter and animate them. The problem appears when uploading the sketch. When I go to uploading the sketch I get this error and the UNO dissapears from the port menu.

Sketch uses 5834 bytes (18%) of program storage space. Maximum is 32256 bytes.
Global variables use 1042 bytes (50%) of dynamic memory, leaving 1006 bytes for local variables. Maximum is 2048 bytes.
/private/var/folders/7t/592nw3054xqb3c05ylm_gvb40000gn/T/AppTranslocation/9C9A32ED-3DB1-4114-907F-8FFD15195A97/d/Arduino.app/Contents/Java/hardware/tools/avr/bin/avrdude -C/private/var/folders/7t/592nw3054xqb3c05ylm_gvb40000gn/T/AppTranslocation/9C9A32ED-3DB1-4114-907F-8FFD15195A97/d/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf -v -patmega328p -carduino -P/dev/cu.usbmodem141401 -b115200 -D -Uflash:w:/var/folders/7t/592nw3054xqb3c05ylm_gvb40000gn/T/arduino_build_317003/ledmatrixtest.ino.hex:i 

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "/private/var/folders/7t/592nw3054xqb3c05ylm_gvb40000gn/T/AppTranslocation/9C9A32ED-3DB1-4114-907F-8FFD15195A97/d/Arduino.app/Contents/Java/hardware/tools/avr/etc/avrdude.conf"
         User configuration file is "/Users/u6077250/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port                    : /dev/cu.usbmodem141401
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: ser_open(): can't open device "/dev/cu.usbmodem141401": No such file or directory

avrdude done.  Thank you.

Problem uploading to board.  See https://support.arduino.cc/hc/en-us/sections/360003198300 for suggestions.

I tried this on the original arduino and also on the rev3 and they both give me the same problem. I am on a mac have tried it on 2 macs at the moment. Here is the sketch of the whole thing:

#define FASTLED_INTERNAL
    #include <FastLED.h>
    #define NUM_LEDS 256
    #define DATA_PIN 6
    #define MATRIX_WIDTH 32
    #define MATRIX_HEIGHT 8 
    
CRGB leds[NUM_LEDS];

void setup() { 
  Serial.begin(9600); 
  FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS); 
  FastLED.setBrightness(50);
  pinMode(LED_BUILTIN, OUTPUT);
}

int translateToDin (int x, int y) {
  if(x%2 == 0) {
    return (8 * x)  + y;  
  } else {
    return (8 * x)  + (8-y-1);
  }
  
}

int randled = 0;

void putInBuffer(int position, CRGB matrix[8][8], int row, int column) {
  for(int i = 0; i<row;i++) {
    for(int j = 0; j<column;j++) {
      leds[translateToDin(i+position,j)] = matrix[j][i];
    }
  }
}
int looper = 0;
void loop() {

//            leds[0] = CRGB::Blue;
//            leds[1] = CRGB::Red;
//            leds[2] = CRGB::Yellow;
//            leds[3] = CRGB::Black;
//            leds[4] = CRGB::Orange;
//            leds[5] = CRGB::White;

//need to specify a matrix in a grid
//need a way to move the matrix in the whole buffer
            CRGB yellowblack[8][8] = {
              {CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow},
              {CRGB::Black, CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow},
              {CRGB::Black, CRGB::Black, CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow},
              {CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow},
              {CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow},
              {CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Yellow,CRGB::Yellow,CRGB::Yellow},
              {CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Yellow,CRGB::Yellow},
              {CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Yellow}
            };

            CRGB redyellow[8][8] = {
              {CRGB::Red,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Red,CRGB::Red,CRGB::Red},
              {CRGB::Red,CRGB::Red,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Red,CRGB::Red},
              {CRGB::Red,CRGB::Red,CRGB::Red,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Red},
              {CRGB::Red,CRGB::Red,CRGB::Red,CRGB::Red,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow},
              {CRGB::Red,CRGB::Red,CRGB::Red,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Red},
              {CRGB::Red,CRGB::Red,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Red,CRGB::Red},
              {CRGB::Red,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Yellow,CRGB::Red,CRGB::Red,CRGB::Red},
              {CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black, CRGB::Black}
            };


            putInBuffer(looper,redyellow,8,8);
            putInBuffer(looper + 8,redyellow,8,8);
            putInBuffer(looper + 16,redyellow,8,8);
            putInBuffer(looper + 24,redyellow,8,8);
            FastLED.show();

           
            //delay(3000);

  randled++;
//  looper++;
//  if(looper==8) {
//    looper = 0;
//  }
}

The problem usually happens when I uncomment the 5 lines at the bottom on the sketch. I cant figure out what could cause this.

No way. This has nothing with a sketch. It can be something with OS, access to the port or such trivial problem like broken cable.

I know that is what is confusing me. It makes no sense for the sketch to behave this way. I have tried another cable and got the same results. I have tried different laptops, cables and different arduino boards. What else can it be? I even tried a powered usb hub instead of a regular usb hub

Fascinating. Looks as if your buffer is overrunning and upsetting the arduino's USB connectivity.

I have had a similar issue after allowing an array to over run .

Maybe a power issue ( supplying Leds) ? Will it up load with them disconnected ?

Best to go back to basics and see if blink will upload to identify the problem area

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