Program termination?

Hi, I am experiencing a problem in the code written below. In this code , only first line in void loop runs continuously. I can't see LED at 13 to switch off. Is there any problem with my arduino mega?

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

void loop() {
   // Clears the trigPin
  digitalWrite(13,1);
  delay(1000);
  digitalWrite(13,0);
}

Maybe another delay after second digital write would help.

3 Likes

try this

void loop() {
   // Clears the trigPin
  digitalWrite(13,1);
  delay(1000);
  digitalWrite(13,0);
  delay(1000);
}
2 Likes

The loop repeats so fast, try adding a 2nd delay:

void loop() {
   // Clears the trigPin
  digitalWrite(13,1);
  delay(1000);
  digitalWrite(13,0);
  delay(1000);
}
2 Likes

Thanks

Try this:

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

void loop() {
  digitalWrite(13,!digitalRead(13));
  delay(1000);
}

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.