Uploads but does not execute

I should start by saying that I only use Arduinos for very basic programming, mainly LEDs and the odd motor or relay. I have started encountering the most peculiar of problems where all new sketches upload perfectly but do not execute any actions at all. If I take an old sketch and modify it then it works fine but all new sketches, even basic ones, will not run. For example, can you see any problem with this test sketch:
int two = 3;
int three = 4;
int four = 5;
int five = 6;
int six = 7;

void setup() {

pinMode (two, OUTPUT);
pinMode (three, OUTPUT);
pinMode (four, OUTPUT);
pinMode (five, OUTPUT);
pinMode (six, OUTPUT);

}

void loop() {

digitalWrite (two, HIGH);
digitalWrite (three, HIGH);
digitalWrite (four, HIGH);
digitalWrite (five, HIGH);
digitalWrite (six, HIGH);

delay (5000);
digitalWrite (two, LOW);
digitalWrite (three, LOW);
digitalWrite (four, LOW);
digitalWrite (five, LOW);
digitalWrite (six, LOW);

delay (5000);

}
I have tried using three varieties of board including new out of the bag and the results are the same. I have downloaded the latest software without any change. The files are marked Arduino 1.8.9

I would be very grateful indeed for any ideas on what is causing this! Thanks.

What is attached to the output pins?

Have a look here

Edit your post with the :pencil2: down here :point_down: and use the code tags <|> up here :point_up_2: to make your code easy to read.

You might want to ask a moderator using the flag icon to move to a more relevant section

1 Like

Just a single LED and suitable resistor to each pin

Thanks. Please excuse my errors - I will try "to do better next time"!

How do you know they 'upload perfectly' ?

Only in so much that the dialogue reaches "Done uploading" and both red LEDs on the board are lit. No different to any of the old sketches that still work as they ever did. Looking at variables between working and non-working sketches only seems to show that sketches created in the last two weeks have the problem. But I can see nothing that has changed!

Hi,
see if you connected the LED correctly.
LED has polarity.
If is inverted it does not light up.

Does the LED resistor go to GND or +V?

You can test the polarity of the LED with a resistor connecting like the figure below.

image

Thanks but I am fully OK with LEDs and polarity.

Have you changed the board in the ide by mistake

I tend to put code like this at the start of a program;

Serial.begin(9600);
Serial.println(F("1_LED_Blink Starting"));

If you dont see the message in the IDE Serial monitor then its very likely the program did not upload and run.

Incidently, have I missed something, I cannot see a reference to the Arduino you are using ?

Are you using the desktop IDE or the web one.

There was a recent discussion where web based sketches were reported as being uploaded successfully but failed to run as expected. Using the desktop IDE to load the sketch showed that there were upload errors that weren't reported by the web based tools.

What happens when you upload the Blink sketch? Does the on board LED flash?

No. I've used different boards but always tried each board with working sketches so I think we can say the boards themselves and settings for each board are all OK.

Yes. The blink sketch works fine as do older sketches that I have written for similar basic tasks.

I'm using the desktop IDE, as I've always done so no changes to my routine that I can see.

I'm sorry but I've never used the serial print option. I'm using clone Uno R3 boards but have also tried a Nano and have used both previously used boards and a brand new one. Again, they all work with my old sketches.

Can you turn on verbose upload in Prefs and post the output

That is a strange statement. Why would that prevent you from using it now, or in future?

Fair enough.

I was suggesting a very simple way that you could work out if your sketches were working. My apoligies for trying to help.