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.
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:
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.
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 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.