I am facing a total weird problem one set of code is running and other ain't. Kindly help
This code isn't working
int pin = 2;
void setup() {
// put your setup code here, to run once:
pinMode(pin, OUTPUT);
digitalWrite(pin, LOW);
}
void loop() {
// put your main code here, to run repeatedly:
}
This code is working
int pin = 2;
void setup() {
// put your setup code here, to run once:
pinMode(pin, OUTPUT);
digitalWrite(pin, LOW);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(pin,HIGH);
delay(5000);
digitalWrite(pin,LOW);
delay(5000);
}
i am using the pin 2 to control the LED
in both codes the led is set digitialWrite(pin,LOW); but in one code the led is not setting off......it is should be off in both codes because it is set a low digitialWrite(pin,LOW);
imran403:
i am using the pin 2 to control the LED
in both codes the led is set digitialWrite(pin,LOW); but in one code the led is not setting off......it is should be off in both codes because it is set a low digitialWrite(pin,LOW);
Doesn't follow at all. The LED is on when current flows through it. That can be due to a pin being HIGH,
or it can be due to a pin being LOW, depending on how its wired up.