Upload error Arduino Nano

Hello i try to upload this scetch to my Arduino nano but it doesn't work, have anyone a idea? i try to restart trhe software and my pc, but it still not working.
The error code is:
avrdude: ser_open(): can't set com-state for "\.\COM22"

And this is the Code:

#include <Wire.h>

int faderA0_1 = analogRead(A0); //soloFader 1
int faderA1_2 = analogRead(A1); //soloFader 2
int faderA2_3 = analogRead(A2); //soloFader 3
int faderA3_4 = analogRead(A3); //soloFader 4
int faderA6_5 = analogRead(A6); //soloFader 5
int faderA7_6 = analogRead(A7); //soloFader 6
/*
int faderA0_1_Alt = 0;
int faderA1_2_Alt = 0;
int faderA2_3_Alt = 0;
int faderA3_4_Alt = 0;
int faderA6_5_Alt = 0;
int faderA7_6_Alt = 0;
*/
int recieve = 0;
bool test = false;
bool sendData = false;
bool buttonStat = false;

int Button1 = 2; //midiKnopf 1
int Button2 = 3; //midiKnopf 2
int Button3 = 4; //midiKnopf 3
int Button4 = 5; //midiKnopf 4
int Button5 = 6; //midiKnopf 5
int Button6 = 7; //midiKnopf 6
int Button7 = 8; //midiKnopf 7
int Button8 = 9; //midiKnopf 8
int Button9 = 10; //midiKnopf 9
int Button10 = 11; //midiKnopf 10

/*
int Button1_Alt = 0;
int Button2_Alt = 0;
int Button3_Alt = 0;
int Button4_Alt = 0;
int Button5_Alt = 0;
int Button6_Alt = 0;
int Button7_Alt = 0;
int Button8_Alt = 0;
int Button9_Alt = 0;
int Button10_Alt = 0;
*/
int ButtonI1 = 0;
int ButtonI2 = 0;
int ButtonI3 = 0;
int ButtonI4 = 0;
int ButtonI5 = 0;
int ButtonI6 = 0;
int ButtonI7 = 0;
int ButtonI8 = 0;
int ButtonI9 = 0;
int ButtonI10 = 0;

int Button1_neu = 0;
int Button2_neu = 0;
int Button3_neu = 0;
int Button4_neu = 0;
int Button5_neu = 0;
int Button6_neu = 0;
int Button7_neu = 0;
int Button8_neu = 0;
int Button9_neu = 0;
int Button10_neu = 0;

#define NODE_ADDRESS 2
#define PAYLOAD_SIZE 17
byte nodePayload[PAYLOAD_SIZE];

void setup() {
Serial.begin(9600);
  Wire.begin(NODE_ADDRESS);
  pinMode(Button1, INPUT_PULLUP);
  pinMode(Button2, INPUT_PULLUP);
  pinMode(Button3, INPUT_PULLUP);
  pinMode(Button4, INPUT_PULLUP);
  pinMode(Button5, INPUT_PULLUP);
  pinMode(Button6, INPUT_PULLUP);
  pinMode(Button7, INPUT_PULLUP);
  pinMode(Button8, INPUT_PULLUP);
  pinMode(Button9, INPUT_PULLUP);
  pinMode(Button10, INPUT_PULLUP);
  Wire.onReceive(receiveEvent); // erstelle ein Empfangen-Ereignis
  Wire.onRequest(requestEvent); // erstelle ein Anfrage-Ereignis
  Serial.println("lol");
}

void loop() {
  faderA0_1 = analogRead(A0);
  faderA1_2 = analogRead(A1);
  faderA2_3 = analogRead(A2);
  faderA3_4 = analogRead(A3);
  faderA6_5 = analogRead(A6);
  faderA7_6 = analogRead(A7);

  Button1_neu = digitalRead(Button1);
  Button2_neu = digitalRead(Button2);
  Button3_neu = digitalRead(Button3);
  Button4_neu = digitalRead(Button4);
  Button5_neu = digitalRead(Button5);
  Button6_neu = digitalRead(Button6);
  Button7_neu = digitalRead(Button7);
  Button8_neu = digitalRead(Button8);
  Button9_neu = digitalRead(Button9);
  Button10_neu = digitalRead(Button10);

  if(Button1_neu ==LOW){
    ButtonI1 = 1;
  }else{
    ButtonI1 = 0;
  }
  if(Button2_neu ==LOW){
    ButtonI2 = 1;
  }else{
    ButtonI2 = 0;
  }if(Button3_neu ==LOW){
    ButtonI3 = 1;
  }else{
    ButtonI3 = 0;
  }
  if(Button4_neu ==LOW){
    ButtonI4 = 1;
  }else{
    ButtonI4 = 0;
  }
  if(Button5_neu ==LOW){
    ButtonI5 = 1;
  }else{
    ButtonI5 = 0;
  }
  if(Button6_neu ==LOW){
    ButtonI6 = 1;
  }else{
    ButtonI6 = 0;
  }
  if(Button7_neu ==LOW){
    ButtonI7 = 1;
  }else{
    ButtonI7 = 0;
  }
  if(Button8_neu ==LOW){
    ButtonI8 = 1;
  }else{
    ButtonI8 = 0;
  }
  if(Button9_neu ==LOW){
    ButtonI9 = 1;
  }else{
    ButtonI9 = 0;
  }
  if(Button10_neu ==LOW){
    ButtonI10 = 1;
  }else{
    ButtonI10 = 0;
  }

  /*if(Button1_Alt != Button1_neu || Button2_Alt != Button2_neu || Button3_Alt != Button3_neu || Button4_Alt != Button4_neu || Button5_Alt != Button5_neu || Button6_Alt != Button6_neu || Button7_Alt != Button7_neu || Button8_Alt != Button8_neu || Button9_Alt != Button9_neu || Button10_Alt != Button10_neu){
    buttonStat = true;
  }else{
    //Serial.println("nicht gedrückt");
  }*/
  
}

void receiveEvent(int bytes) {
  recieve = Wire.read();              // lies die gesendeten Daten aus
   if(recieve==255){
    test = true;
   }
   if(recieve==254){
    sendData = true;
   }

  Serial.println(String(recieve) + ": recieve" + " test: " + test + " sendData: " + sendData);
}

void requestEvent()
{
  Serial.println("buttonStat: " + String(buttonStat) + " sendData: " +sendData);
  //Serial.println(String(faderA0_1_Alt) + " " + faderA0_1 + " " + faderA1_2_Alt + " " + faderA1_2 + " " + faderA2_3_Alt + " " + faderA2_3 + " " + faderA3_4_Alt + " " + faderA3_4 + " " + faderA6_5_Alt + " " + faderA6_5 + " " + faderA7_6_Alt + " " + faderA7_6);
  //if(buttonStat == true || sendData == true || (faderA0_1_Alt != faderA0_1)  ||  (faderA1_2_Alt != faderA1_2)  ||  (faderA2_3_Alt != faderA2_3)  ||  (faderA3_4_Alt != faderA3_4)  ||  (faderA6_5_Alt != faderA6_5)  ||  (faderA7_6_Alt != faderA7_6)){
  nodePayload[0] = NODE_ADDRESS;
  nodePayload[1] = faderA0_1 / 4;
  nodePayload[2] = faderA1_2 / 4;
  nodePayload[3] = faderA2_3 / 4;
  nodePayload[4] = faderA3_4 / 4;
  nodePayload[5] = faderA6_5 / 4;
  nodePayload[6] = faderA7_6 / 4;
  
  nodePayload[7] = ButtonI1;
  nodePayload[8] = ButtonI2;
  nodePayload[9] = ButtonI3;
  nodePayload[10] = ButtonI4;
  nodePayload[11] = ButtonI5;
  nodePayload[12] = ButtonI6;
  nodePayload[13] = ButtonI7;
  nodePayload[14] = ButtonI8;
  nodePayload[15] = ButtonI9;
  nodePayload[16] = ButtonI10;

/*
  faderA0_1_Alt = faderA0_1;
  faderA1_2_Alt = faderA1_2;
  faderA2_3_Alt = faderA2_3;
  faderA3_4_Alt = faderA3_4;
  faderA6_5_Alt = faderA6_5;
  faderA7_6_Alt = faderA7_6;

  Button1_Alt = Button1_neu;
  Button2_Alt = Button2_neu;
  Button3_Alt = Button3_neu;
  Button4_Alt = Button4_neu;
  Button5_Alt = Button5_neu;
  Button6_Alt = Button6_neu;
  Button7_Alt = Button7_neu;
  Button8_Alt = Button8_neu;
  Button9_Alt = Button9_neu;
  Button10_Alt = Button10_neu;
  
  sendData = false;
  buttonStat = false;*/
  Serial.println("data send" + String(nodePayload[0]));
  Wire.write(nodePayload, PAYLOAD_SIZE);
  /*}else if(test==true){
    nodePayload[0] = NODE_ADDRESS;
    nodePayload[1] = 255;
    nodePayload[2] = 255;
    nodePayload[3] = 255;
    nodePayload[4] = 255;
    nodePayload[5] = 255;
    nodePayload[6] = 255;
    Wire.write(nodePayload, PAYLOAD_SIZE);
    test = false;
    Serial.println("test passed");
  }else{
    //Wire.write(nodePayload, PAYLOAD_SIZE);
    Serial.println("nicht gesendet");
  }*/
  //Wire.write(nodePayload, PAYLOAD_SIZE);
  
}

In the Tools menu, when you select your board as Arduino Nano, look at the next setting below called Processor. Try changing this to "ATmega328P (Old Bootloader) and uploading your sketch again.

Is Serial Monitor in Arduino IDE open?

Hi @miene3. Please tell us which USB to serial adapter chip your Arduino board has. This is the largest black chip on the bottom of the board.

The chip will usually be identified by writing on the top. This might say something like "WCH CH340G" or "FTDI FT232RL".

Examples:

WCH CH340

CH340

📷

SparkFun - CC BY-SA 4.0 (cropped)

FTDI FT232R

📷

ICIC-SS28-X-K232-01 by oomlout - CC BY-SA 2.0 (cropped)


If it isn't clear, alternatively you can provide the link to where you bought the board from and we'll see if we can determine the chip from the product listing.

The same thing happens to me, only that in the drive that it has, no nomenclature appears

Hi @oskr0309

I'm going to ask you to post some additional information that might help us to identify the problem.


:exclamation: This procedure is not intended to solve the problem. The purpose is to gather more information.


Please do this:

  1. If you don't still have the IDE or web editor open with the error present, repeat the process that generated it.
  2. You now need to copy the full and exact text of the output.
    The procedure for doing this is different depending on which Arduino development software you are using:
    • Arduino IDE 1.x: Click the Copy error messages button on the right side of the orange bar in the IDE.
    • Arduino IDE 2.x: Right click on the black "Output" panel at the bottom of the IDE window and then select "Copy All" from the context menu.
    • Arduino Web Editor: Click the icon that looks like two pieces of paper at the top right corner of the black console window Web Editor.
  3. Open a forum reply here by clicking the Reply button.
  4. Click the <CODE/> icon on the post composer toolbar.
    This will add the forum's code block markup (```) to your reply to make sure the error messages are correctly formatted.
    Code tags icon on toolbar
  5. Press Ctrl+V.
    This will paste the compilation output into the code block.
  6. Move the cursor outside of the code block markup before you add any additional text to your reply.
  7. Click the Reply button to post the output.

In case the output is longer than the forum software will allow to be added to a post, you can instead save it to a .txt file and then attach that file to a reply here:

  1. Open any text editor program.
  2. Paste the copied output into the text editor.
  3. Save the file in .txt format.
  4. Open a forum reply here by clicking the Reply button.
  5. Click the "Upload" icon (image) on the post composer toolbar:
    Upload icon on toolbar
    A dialog will open.
  6. In the dialog, select the .txt file you saved.
  7. Click the Open button.
  8. Click the Reply button to publish the post.

Alternatively, instead of using the "Upload" icon on the post composer toolbar as described in steps (5) - (7) above, you can simply drag and drop the .txt file onto the post composer field to attach it.

I see @oskr0309 created a dedicated topic for discussion of the upload error they are experiencing:

I'll provide support over there.

A post was merged into an existing topic: Avrdude: ser_open(): can't set com-state for "\.\COM10"

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