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
b707
July 20, 2023, 6:25am
3
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
Try this:
void setup() {
pinMode(13,OUTPUT);
}
void loop() {
digitalWrite(13,!digitalRead(13));
delay(1000);
}
system
Closed
January 16, 2024, 4:02pm
7
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.