0
#include <Arduino.h>

void setup()
 {
  pinMode(13, OUTPUT);
 }
void loop()
{
 digitalWrite(13, HIGH);
 delay(1);
 digitalWrite(13, LOW);
 delay(1);
}

I am trying to make an led glow for one second to glow and then go off but nothing happens

2
  • 1
    how did produce a wrong version of the most basic Arduino example? arduino.cc/en/Tutorial/BuiltInExamples/Blink
    – Juraj
    Commented Oct 29, 2020 at 6:35
  • 1
    Your first step when facing such a problem is to read the documentation. You have 3 functions in your code, which as read in a short time, less than 5 minutes. You would have found the delay() expects the interval in milliseconds. Please do so the enxt time. Commented Oct 29, 2020 at 14:01

2 Answers 2

3
#include <Arduino.h>

void setup()
 {
  pinMode(13, OUTPUT);
 }
void loop()
{
 digitalWrite(13, HIGH);
 delay(1000);
 digitalWrite(13, LOW);
 delay(1000);
}

The problem with your code is that the delay function works in milliseconds and not seconds . 1sec = 1000ms .

5
  • 1
    thanks it is working now
    – arduino
    Commented Oct 28, 2020 at 18:49
  • 4
    what is next? The "Bare Minimum" example without loop()?
    – Juraj
    Commented Oct 28, 2020 at 19:59
  • 1
    True but just go a little easy in the newbie
    – xbox gamer
    Commented Oct 28, 2020 at 21:30
  • @Juraj: The Bare Minimum Blink (arduino.cc/en/Guide/ArduinoUno#open-your-first-sketch ) works without the line #include <Arduino.h> Commented Oct 28, 2020 at 21:52
  • I use platform io for programing so in that it is important to include arduino.h maybe the person who asked is also using platform io or something similar
    – xbox gamer
    Commented Oct 28, 2020 at 22:05
1

by increasing the delay value, you can visualize it better.

{

 digitalWrite(13, HIGH);

 delay(2000);

 digitalWrite(13, LOW);

 delay(1000);

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.