did you do a cross checking with putting the same code into loop()? Just to see if the LED is blinking there?
This is to ensure that the hardware-wiring is working
Thank you.
Got it work using the alreadyBlinked code:
int ledPin = 4;
int alreadyBlinked = 0;
void setup () {
pinMode(ledPin, OUTPUT);
}
void loop () {
if(alreadyBlinked == 0)
{
digitalWrite(ledPin, HIGH); // sets the LED on
delay(2000); // waits a period of time
digitalWrite(ledPin, LOW); // sets the LED off
alreadyBlinked = 1;
}
}
Which makes us all wonder what was actually wrong with the way you tried it first, which should have done the same thing.
What did your original attempt do? What else besides the code must you have changed?
“The” alreadyBlinked code (!) is a kludge. While effective you shouldn’t go off thinking that setup() is inadequate to the task of performing some things one time at the beginning… that’s what and all it is meant for.
I tested the blink-once in setup-code code on an Arduino-Uno with the onboard-LED (= pin 13)
did exactly what is expected. LED goes on for one second LED goes off
You are a bit lazy about code-formatting. If you press Ctrl-T in the Arduino-code.editor the code gets formatted for you.
In such a small code it does not matter if you have each line indented a different number of spaces. In bigger code correct indentnion will help to find missing or overcounted curly brackets "{}"