[SOLVED] Having problems uploading Arduino code

I'm having trouble uploading a simple program to my Arduino Uno.

Using an analog pin to read the closing of a switch and outputing it through a digital pin

Here's the code: int PinA=4; bool a=false; bool B=false;

void setup(){ pinMode(A0, INPUT); pinMode(PinA, OUTPUT); Serial.begin(9600);

} void loop(){ B=digitalRead(A0); a=B; digitalWrite(PinA,a); }

Arduino: 1.8.13 (Windows 10), Board: "Arduino Uno"

Sketch uses 1896 bytes (5%) of the program storage space. The maximum is 32256 bytes.

Global variables use 184 bytes (8%) of dynamic memory, leaving 1864 bytes for local variables. The maximum is 2048 bytes.

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

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

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

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

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

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

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

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

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

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

You are probably trying to upload to wrong port.

.

ieee488: You are probably trying to upload to wrong port.

I made sure I was uploading it to the correct port

.

Remove any connections to pins 0 and 1 on your Arduino board. These pins are used for communication with your computer, including uploads. Connecting anything to these pins can interfere with uploads.

Make sure you have the correct board selected from the Tools > Board menu. Note that some boards have similar names, but are not interchangeable. Examples include "Arduino Uno" vs. "Arduino Uno WiFi" vs. "Arduino Uno WiFi Rev2".

pert:
Remove any connections to pins 0 and 1 on your Arduino board. These pins are used for communication with your computer, including uploads. Connecting anything to these pins can interfere with uploads.

Make sure you have the correct board selected from the Tools > Board menu. Note that some boards have similar names, but are not interchangeable. Examples include “Arduino Uno” vs. “Arduino Uno WiFi” vs. “Arduino Uno WiFi Rev2”.

The I refer to as A0 is the analog pin A0, I don’t have any connections on the digital pins 0 or 1 (which are the ones I think you are talking about), and I made sure i had the right board selected too

patold388: I don't have any connections on the digital pins 0 or 1 (which are the ones I think you are talking about)

That's correct. Digital pins 0 and 1.

Even though pins 0 and 1 are most likely to be the culprits behind an upload failure, it is possible for a high current draw to interfere with uploads. So please disconnect all circuitry, wiring, modules, shields, etc. from the Uno and try uploading to just the board alone. Let us know what the results are of that.

pert: That's correct. Digital pins 0 and 1.

Even though pins 0 and 1 are most likely to be the culprits behind an upload failure, it is possible for a high current draw to interfere with uploads. So please disconnect all circuitry, wiring, modules, shields, etc. from the Uno and try uploading to just the board alone. Let us know what the results are of that.

Same output on console :(

If you press and release the reset button on the Uno, does the "L" LED blink quickly several times?

pert: If you press and release the reset button on the Uno, does the "L" LED blink quickly several times?

Yep

OK, that means the bootloader is working. The next step is to try the loopback test to see whether the USB chip is working fully.

Note: the loopback test will always fail on the derivative Arduino boards that use a CH340 USB chip, so there's no point in doing it on those boards.

  • Disconnect power from the board.
  • Remove all connections and shields from the board.
  • Force the processor to remain in reset by connecting a jumper wire from the RESET to the GND pin.
  • Connect a jumper from the RX pin (Arduino pin 0) to the TX pin (Arduino pin 1).
  • Connect the board to your computer.
  • Select the port of your board from the Tools > Port menu.
  • Tools > Serial Monitor
  • Type some text into the input field at the top of the Serial Monitor window.
  • Press Enter. If the text you typed is shown in Serial Monitor's output window, the loopback test passed. If the text was not shown, the loopback test failed.
  • Close Serial Monitor.
  • Disconnect the board from the computer.
  • Remove the two jumper wires.

If the loopback test failed, the USB to TTL serial adapter is damaged and it's unlikely to be worth repairing your board.

pert: OK, that means the bootloader is working. The next step is to try the loopback test to see whether the USB chip is working fully.

Note: the loopback test will always fail on the derivative Arduino boards that use a CH340 USB chip, so there's no point in doing it on those boards.

  • Disconnect power from the board.
  • Remove all connections and shields from the board.
  • Force the processor to remain in reset by connecting a jumper wire from the RESET to the GND pin.
  • Connect a jumper from the RX pin (Arduino pin 0) to the TX pin (Arduino pin 1).
  • Connect the board to your computer.
  • Select the port of your board from the Tools > Port menu.
  • Tools > Serial Monitor
  • Type some text into the input field at the top of the Serial Monitor window.
  • Press Enter. If the text you typed is shown in Serial Monitor's output window, the loopback test passed. If the text was not shown, the loopback test failed.
  • Close Serial Monitor.
  • Disconnect the board from the computer.
  • Remove the two jumper wires.

If the loopback test failed, the USB to TTL serial adapter is damaged and it's unlikely to be worth repairing your board.

That was it, my TTL is damaged, luckily i have a Leonardo and it worked fine on that one, thanks for all your help

ISSUE FOUND- TTL ON ARDUINO UNO DAMAGED

Thanks for taking the time to post an update with your findings. I'm sorry to hear that your Uno is damaged, but at least now you know where the problem is.

Even though it's not very convenient, there is still the possibility of uploading to the Uno either via a separate USB to TTL serial adapter module or cable (AKA "FTDI") or an ISP programmer (you can even use your Leonardo as an "Arduino as ISP"). So you might stash the Uno away in case it will be usable later in a project where you won't need to upload to the board often.