delay ( )
The delay() function serves as a tool to halt program execution for a specified duration, measured in milliseconds. We have seen how delay(5000) signifies a stop of 5 seconds.
This can be understood by the fact that 1 second equals 1000 milliseconds.
Code:
digitalWrite (12, HIGH);
delay (5000);
digitalWrite (12, LOW);
delay (2000);
The program here is that the LED is connected to the pin having PIN 12 and it will remain lit for 5 seconds before turning and then will go off. The LED will then be turned off for 2 seconds as specified by delay(). This cycle will continue in a loop depending on the defined variables within the void loop() function.
Arduino Coding Basics
In some previous articles, we have seen and understood the concepts of Arduino Boards, Arduino IDEs, and the installation procedure for Arduino software. Arduino IDE (Integrated Development Environment) is an essential which makes the task of uploading code on Arduino boards, an easy task. Instead of writing them at the assembly level, the IDEs make it convenient and the codes are written in high-level languages like C and C++. Let us get introduced to the basics of Arduino Coding.
Make sure that you have an appropriate IDE for coding before starting your journey to Arduino coding. Let us study every character, command, and function that is used in Arduino. Keep your Arduino IDE switched on so that you can apply the concepts you learn from the article.
Table of Content
- What is Arduino?
- Electronic Signals
- Brackets
- Line Comment
- Coding Screen
- Time
- pinMode ( )
- digitalWrite( )
- delay ( )
- Solved Example
- Advantages and Disadvantages of Arduino
- Application of Arduino