I've just bought brand new arduino nano board. I wrote some code and uploaded it to the board. Everything worked fine until I made some changes to the code and tried to upload it again. It doesn't seem to be the code issue because it happens even with empty sketch. If i edit an existing sketech and try to upload it, I get an error saying that acces to COM port is denied... Tried to fix that with device maneger and changing the port number but that didn't work.
#define joyX A0
#define joyY A1
int xValue, yValue;
void update_joystick() {
xValue = analogRead(joyX);
yValue = analogRead(joyY);
Serial.print("X: ");
Serial.print(xValue);
Serial.print(" Y: ");
Serial.println(yValue);
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
update_joystick();
}
that's the code i was working with, the changes I made were to map the xValue and yValue.
If I open new sketch and paste the code, it uploads. But I have to do it every time I change something in the code.
It appears you have a serial flood, you are sending more then the uart can process. Take these steps and upload the blink sketch:
Power off the board completely
Remove the USB cable
Hold down the Reset button
keep it held down (or, run a jumper wire from the RESET pin to the GND pin).
Still holding down Reset reconnect the USB cable.
Start uploading a sketch that does not have this problem (I use the Blink sketch).
When you see the Receive light blink, release the Reset button
Note: I have seen this happen several times when I flood the serial output. An indication is the tx light is stuck on.