Cant reset, stop arduino code

so today i wanted to create smthing like calculator in serial monitor, and tried this code by chatgpt

const int buttonPin = 2; // пин, к которому подключена вторая провода
int buttonState = 0;

void setup() {
  pinMode(buttonPin, INPUT_PULLUP);  // Включаем внутренний подтягивающий резистор
  Serial.begin(9600);
}

void loop() {
  buttonState = digitalRead(buttonPin);

  if (buttonState == LOW) { // контакты соединены (пин замкнут на GND)
    Serial.println("Кнопка нажата (контакты соединены)");
    // здесь можно включить светодиод или вызвать другую функцию
  } else {
    Serial.println("Кнопки не нажаты");
  }
  
  delay(200);
}

so now i cant upload any other code, and burn a bootloader, and everything, tried resetting, and i need yours help cuz i want to reset it (or smthing like that) so no code runs
(sorry for bad english)

Welcome to the forum

Is the sketch that you posted working ?

What happens when you try to upload a new sketch ?

Which Arduino board are you using ?

Arduino will run some code everytime. It cannot “not run code”.

You can upload different code to your Arduino and it will run that instead.

You can upload empty loop, and it will not say anything, just silently looping.

void loop() {}

sketch working.
just does this error:
Скетч использует 444 байт (1%) памяти устройства. Всего доступно 30720 байт.
Глобальные переменные используют 9 байт (0%) динамической памяти, оставляя 2039 байт для локальных переменных. Максимум: 2048 байт.
avrdude: ser_open(): can't open device "\.\COM3": �������� � �������.
arduino nano v3.0

cant upload, it just gives this error:
Скетч использует 444 байт (1%) памяти устройства. Всего доступно 30720 байт.
Глобальные переменные используют 9 байт (0%) динамической памяти, оставляя 2039 байт для локальных переменных. Максимум: 2048 байт.
avrdude: ser_open(): can't open device "\.\COM3": �������� � �������.

Check the COM port setting in Tools/Port (the \.\ part is suspicious). If the port really exist and is selected, then try press RESET button on the Arduino, start uploading and immediately release the RESET button.

also the tx light is blinking

still doesnt works, the serial port looks normal

tried it and after several attempts it give this coman
C:\windows\temp\ccfq42Ye.ltrans0.ltrans.o: In function main': C:\Users\User\AppData\Local\Arduino15\packages\arduino\hardware\avr\1.8.6\cores\arduino/main.cpp:43: undefined reference to setup'
collect2.exe: error: ld returned 1 exit status
exit status 1

Compilation error: exit status 1

Sorry, it was just shortcut. The whole program should look like this

void setup(){}
void loop(){}

Just indicates you've got something in the running code doing a Serial.write() or Serial.print(). Which you do.

But your error message makes me think you've got a bad USB cable, or other basic connectivity problem. Unplug, replug your USB cable, both ends, one at a time, trying your compile/upload between each change, and report back.

You've posted in the Every category - do you really have a genuine Nano Every? New visitors often post in the wrong category.

Also, one common newbie error is for the pins on the Arduino to have been pushed into the holes, but not soldered - could you post a picture of your setup, please? If they're not soldered, they will make contact, but not reliably. You might go for hours with successful uploads, then suddenly, nothing, then something, then nothing, etc.

@platnotap
What is your Arduino board?
According to the compile message, it seems to be a Uno or classic Nano...

If it is a Nano - could you try to select an "Old bootloader" option in the microcontroller menu?

Скетч использует 444 байт (1%) памяти устройства. Всего доступно 30720 байт.
Глобальные переменные используют 9 байт (0%) динамической памяти, оставляя 2039 байт для локальных переменных. Максимум: 2048 байт.

The sketch uses 444 bytes (1%) of device memory. The total available memory is 30,720 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2,039 bytes for local variables. Maximum: 2,048 bytes.

If this is an official Classic Nano with FT232 serial-to-usb converter, close the serial monitor.

Based on the memory usage reported by the IDE you're not using a Nano Every and therefore your topic has been moved a a more suitable location on the forum.



i thinked that nano every means like every arduino nano

already tried that, still doesnt work, but i found a way i can upload code with void loop so it finally maybe works

Please give details of what you changed that allowed you to upload code

What you said makes no sense

I unplug arduino out of pc, and plug back in, and then when it not runs any code upload new code on it, maybe it works, and again sorry for my bad english

The second image in post 17 does not show any print on the IC marked in red.

Can you confirm that there is no print on it; it should look like below


Where you can clearly read the print (WCH CH340G)

If there is no print on it, the solution might be to roll back the driver; see Port monitor error: command 'open' failed: Invalid serial port. Could not connect to COM serial port - #49 by ptillisch