digitalWrite( )
The digitalWrite( ) function is used to decide the value of the pin. It can be set as either of the two values, HIGH or LOW.
HIGH: For a board that is supplied with a maximum of 1V, it results in a 5V value whereas on a board with other values like 6V, it updates the value to 6V.
LOW: It sets the pin to the ground by setting a reference of 0V.
If no pin is set with pinMode as OUTPUT, the LED may light dim.
The syntax is:
digitalWrite( pin, value HIGH/LOW)
Pin: We can specify the PIN or the declared variable.
Let’s understand with an example.
Example:
digitalWrite (6, HIGH);
digitalWrite (6, LOW);
The HIGH will be used for setting the pin at number 6 high and it will ultimately turn on the LED if connected to this pin while, the LOW will be used for setting the pin at number 6 low and it will ultimately turn off the LED if connected to this pin.
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