Program not working after I changed LED circuit

I got a new Arduino Uno board. As part of the test, when I first connected, the "L" LED was blinking. Then I connected a simple LED circuit to test if the boards are working.

The sketch I uploaded is :

#define LED_PIN 12
void setup()
{
pinMode(LED_PIN, OUTPUT);
}
void loop()
{
digitalWrite(LED_PIN, HIGH);
delay(500);
digitalWrite(LED_PIN, LOW);
delay(500);
}

So for the first pass, my circuit was connected to pin 12 and it worked. Then I changed the sketch code to pins 9, 10 and 13, and tried out using connections pins 9, 10 and 13 respectively. I wasn't able to run the program successfully anymore. What went wrong ?

You missed the correct breadboard holes.

You have posted your question to an existing thread.
You should have posted a new thread.
Please report/flag your post and kindly ask a moderator to split it off.

You have not posted your code in code tags like advised in the forum how to.
Read again the forum how to how to post code in code tags.

Edit your post and put the code in code tags.

You don't have a solid ground connection.
Try again with a circuit like shown here:
https://docs.arduino.cc/built-in-examples/digital/BlinkWithoutDelay/

Please don't hijack threads @koofnik_ubk . I have split your post out to its own topic.

Hijacking is against the Arduino forum rules. The reason is that it may sidetrack the discussion, even preventing the creator of the topic from getting the assistance they need. It also reduces your own chances of getting assistance.

This is basic forum etiquette, as explained in the "How to get the best out of this forum" guide. It contains a lot of other useful information. Please read it.

Thanks in advance for your cooperation.

The wires and components on the breadboard look to be correctly positioned AFAICT. The LED pin positions were hard to spot, but the shadow of its legs show which holes they go in. The LED looks the right way round, the flat appears to be on the right hand side.

So if you just move the wire A from 13 to 12, #define LED_PIN 12, compile and upload it works (blinks). But if you then move the wire from A to any of [9,10,13], #define LED_PIN to matching pin [9,10,13], compile and upload it doesn't work. Have I understood correctly?

I got it working. You read my diagram correctly. Thanks.

I am not trying to hijack a forum. Before typing my question, I actually looked through if there were equivalent topics by selected titles, not all detailed contents in those titles.
I also started by typing "how to start a new post" under the search box and it did not yield a direct source for me to start a new post.

What was the problem?

I don't think I managed to pinpoint the problem.
Like you said, when I moved a wire from e.g. pin 9 and used a matching pin in the code, compile and upload, it should work. After a few rounds when it didn't, I did 2 things :
(a) I turned my machine off and restarted the Arduino.
(b) I changed my wires that have kinks at the end to those without. On a conservation basis, I originally try to use wires even though the ends may come with kinks, but unfortunately some kinks can become 'brittle' over time too.
When I restarted my machine, the problem went away.

1 Like