Created
August 16, 2021 01:15
-
-
Save astro648/e57db89828dcba4ce22380a0b530b6aa to your computer and use it in GitHub Desktop.
Flashing LED Light Arduino Code with Basic Explanations
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//(Remember to use the Arduino IDE) Let's say that you want to make a flashing LED light. | |
//In this specific example, the LED is connected to Pin 2. | |
void setup(){ | |
//Setting up the output for Pin 2 | |
pinMode(2,OUTPUT); | |
} | |
//In the Arduino IDE, void loop(){} loops the code inside curly brackets. | |
void loop(){ | |
//The line of code below turns on the light. | |
digitalWrite(2,HIGH); | |
//This line keeps it on for 50ms. | |
delay(50); | |
//This line turns it off. | |
digitalWrite(2,LOW); | |
//This line keeps it off for 50ms. | |
delay(50); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment