Hello all,
I’m facing a problem with uploading new code to my hardware whenever I have a while loop in my code, both a forever while loop, as well as a conditional one.
Board: Sodaq One V3
OS: Windows 10
IDE: Arduino 1.8.13
problem explained
The problem is that whenever and wherever I use a while loop in my code, I am unable to upload code again to the board. I keep hard resetting the board, again and again, and only by chance, I’d be able to program the board again.
What happens is that Arduino IDE tries to upload the code after compiling, and it just does not. It says uploading…, but nothing happens; it freezes. Then I press the reset button, and it throws an error: an error occurred while uploading the code, I try to upload again, and it says that the COM port is busy; I don’t understand why a while loop causes all this pain!
For example, I had a forever while loop in my main loop (the void setup(), void loop(){} I mean ), to prevent sending Lora packets from one point forward, which I then switched to the alternative, introducing some big delays to prevent reprogramming problem.
So, to sum up, my question is, if there is a fundamental reason why a while loop prevents reprogramming the board, and if so, why and how to solve this.
I have already removed all while loop codes I had, so I have only an old example code.
void loop() {
uint8_t packet = 0x0;
String Payload = "";
sendPacket(String(packet)); // also when commented out
receivePacket(Payload); // also when commented out
while(1){
// something
delay(60000);
}
}
Thank you for your time.