What is my mistake?

Hi, I am new at arduino and could not understand something. Code is as below, my question is under the code.

void setup()
{

ledPin[3], OUTPUT);

}

void loop() {

{

//digitalWrite(ledPin[3], HIGH);
delay(2000);
digitalWrite(ledPin[3], LOW);
delay(2000);
}

As you see the last code is "digitalWrite(ledPin[3], LOW);" and "digitalWrite(ledPin[3], HIGH);" code is not activated.

And I guess codes are read from up to down, but although the last code is "digitalWrite(ledPin[3], LOW);" , I always see 5 volts at pin 3.

What makes the pin3 always at 5 volts although I am telling "digitalWrite(ledPin[3], LOW);" as last code ?

And When I active the "digitalWrite(ledPin[3], HIGH);" code, then the led blinks, so arduino read the "LOW" code if I use it together with "HIGH"...

but if I write only "digitalWrite(ledPin[3], LOW);", it does not sense anything for arduino? It always makes pin3 at 5 volt...

I could not understand this issue...
As you know at ccs c, always the last code's order is done. I this is not same for arduino ? If it is different at arduino could you explain my fault please.
Thanks.

Welcome to the forum.

What is the ledPin[3]? It must be defined. This: ledPin[3], OUTPUT); is completly invalid statement. In the examples is the blink sketch. It is working with the LED on the pin 13. If you want to use different pin, just to replace 13 with your e.g. 3.
Function digitalWrite requires number of pin. This will work:

digitalWrite(3, LOW);

Please use [code] tags. To find out what these are, read the sticky posts at the top of the forum. We know that what you have posted is not your sketch, because what you have posted will not compile.

could you explain my fault please

The code that you posted does not compile.

Which pin is the LED connected to and what is the other side of the LED connected to ?

I'm just gonna leave this here:

void setup() {
  pinMode(3, OUTPUT);
}

void loop() {
  digitalWrite(3, HIGH);   
  delay(2000);             
  digitalWrite(3, LOW);   
  delay(2000);              
}

What's up with the comment: //digitalWrite(ledPin[3], HIGH); ?
And there is a curly bracket too much

Thanks for answers. I wrote the first code with cellphone it’s false.
The true one is below.

As you see the last code is “digitalWrite(2, LOW);”

so, when the program works, pin2 must be always at LOW because the last code is “digitalWrite(2, LOW);” , and in my serial monitor, it’s always at “LOW” as we wish. But when I load the code to arduino, pin2 is always at “HIGH”… it’s interesting…

and also if I change last code to “digitalWrite(2, HIGH);” then pin2 is LOW at arduino.

So, there is an invert situation. if my code is “HIGH”, it’s “LOW” in arduino ; and if my code is “LOW”, it’s “HIGH” in arduino…

void setup()
{
pinMode(2, OUTPUT);
Serial.begin(9600);
}

void loop()
{
digitalWrite(2, LOW); // But PIN2 is HIGH in ardunio !!!
delay(5);
int pindurumu=digitalRead(2);
Serial.print(pindurumu);
delay(1000);
}

what could be the problem ?

How is the LED wired to the Arduino ?
Is anything else connected to pin 2 ?

void loop()
{
  digitalWrite(2, LOW);    // But PIN2 is HIGH in ardunio !!!!!!!!!!!!!!!!!!!!!!!!!
  delay(5);
  int pindurumu=digitalRead(2);
  Serial.print(pindurumu);
  delay(1000);
}


what could be the problem ?

Well, you are only setting a low for five milliseconds. But you are setting the high for a full second. If you are reading the voltage with an oscilloscope, you you could see this. Otherwise, to a volt meter, it'll read like its always high.

-jim lee

you are setting the high for a full second

Where ?

UKHeliBob:
Where ?

Good lord, nowhere. I think its late and I'm getting tired..

-jim lee