After my sketch is uploaded, it does not do anything

I noticed a strange addition to my upload data: reset() which does not show on tutorials.
Could this prevent the sketch from being executed?
After pressing the reset button, the sketch is executed.

Example:

[=========================== ] 92% (13/14 pages)write(addr=0x34,size=0x1000)
writeBuffer(scr_addr=0x34, dst_addr=0xd000, size=0x1000)

[==============================] 100% (14/14 pages)
Done in 3.347 seconds
reset()

With the deubber on it shows an error. Don't know what it means:
Open On-Chip Debugger 0.11.0+dev-gab95bac57-dirty (2021-05-11-10:57)
Licensed under GNU GPL v2
For bug reports, read
OpenOCD: Bug Reporting
CDRTOSConfigure
embedded:startup.tcl:26: Error: Can't find interface/{programmer.protocol}.cfg
in procedure 'script'
at file "embedded:startup.tcl", line 26
[2025-02-08T13:09:44.950Z] SERVER CONSOLE DEBUG: onBackendConnect: gdb-server session closed
GDB server session ended. This terminal will be reused, waiting for next session to start...

Welcome to the forum

What sketch would that be ?
Which Arduino board are you using ?
Which version of the IDE are you using ?

2 Likes

What sketch are you using and which Arduino are you using? Not to forget, what is your IDE version?

1 Like

Thanks for the swift response! Actually all sketches, but below is the one I have now. Using an Arduino R4 Wifi ans IDE 2.3.4

int redPin=11;
int bright=50;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(redPin,OUTPUT);
}

void loop() {
// put your main code here, to run repeatedly:
analogWrite(redPin,bright);
}

I'm not sure if 11's a PWM (since Arduino Uno has specific pins and i use Arduino Mega)
What type of not working is it? Pin not working, uno not working?

could you try this code?

int PWM_pin = 3; //since most Arduinos have 3 as PWM
int brightness = 0;

void setup(){
 Serial.begin(9600);
pinMode(PWM_pin,OUTPUT); //comment it out if needed.
}

void loop(){
 for(int i = 0; i < 255; i++){
  Serial.println(i);
 analogWrite(PWM_pin,i);
 delay(100);
  }
 for(int i = 255; i > -1; i++){ 
  Serial.println(i);
  analogWrite(PWM_pin,i);
  delay(100);
  } 
}

And do you see values ranging from 0 to 255 and 255 to 0? do you see LED going dim and bright?

1 Like

Yes I saw the LED going brighter (only in the Serial Monitor I saw it just kept adding up, even after 255). Going back to my sketch, it does not do anything, until I hit the reset button.

Beginning to think my Arduino is faulty...

Aha, there's a little mistake in your code:
for(int i = 255; i > -1; i++) should be i-- :wink:

Going back and forth to either of the sketches, they are not running after upload.

oops my bad, happens to the best of us...

i mean if it ain't working why not get a new one?

Just thought, maybe (as a newbee) I have some settings wrong. And I find it strange that the uploadmonitor ends with reset() everytime, which I do not see at tutorials. Thought maybe it resets my Arduino or something... And the sketches do run after upload: I only have to press the physical reset button on the board. Don't think it should work like that (?)

Hi @leukmannetje.

The presence of the reset() line is normal and expected. The reason you don't see it in the tutorials is because it only appears when you have the Show verbose output during: ☐ upload option enabled in your Arduino IDE preferences. The people making the tutorials must have had that useful setting disabled.

No. You are allowing the reset() line to act as a "red herring" that is distracting you from progressing in your troubleshooting.

This error occurred because you didn't configure Arduino IDE's Tools > Programmer menu. You should select Tools > Programmer > ARM CMSIS-DAP compatible from the Arduino IDE menus when using the debugger with the UNO R4 WiFi board.

However, I should warn you that the debugger is a very advanced feature and isn't necessarily useful for troubleshooting this particular problem.

Please provide a detailed description of what you mean by "does not do anything".

What exactly were you expecting to observe that you did not observe until after pressing the reset button?

Do you have some external circuitry connected to your UNO R4 WiFi board? If so, please provide a detailed description of the circuit. We always prefer such descriptions to be in the form of a schematic diagram, but in the case of a very simple circuit like an LED, a text description will be sufficient, at least as a starting point.

Thank you @ptillisch for this extensive answer. Clear!
What I mean by "does not do anything" is that after uploading a sketch, the internal led blinks fading and the sketch is not executed. Only after I press the reset button once, the sketch is activated. In both cases above the board is quite simple: connected by a 7.5V external power supply, and USB to my Mac, on pin 11 / pin 3 (the other sketch) going to a red Led long leg, then a 1000 resistor after the short leg and then back to gnd on the board.
So uploading sketch->everything goes smooth->sketch loaded->on board led blinking slowly fading->sketch not executed. Then pressing the reset button and the sketch is executed, where on tutorials the sketch begins immediately after uploading.

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