Hi Friends! Hope you are doing well. In this post, I’ll uncover the details on How to use pinMode Arduino Command. The pinMode defines the Arduino Pins, if they are used as an input or output. The INPUT_PULLUP is another option achieved by pinMode, that is mainly used to place a virtual pull-up resistor to the input pins.

We have started Arduino Tutorials for Beginners quite a while now for the newbies, who are really interested to get a hands-on experience with Arduino. Generally, Arduino is known as a Microcontroller, but it is a step ahead of it. The PIC microcontrollers require some basic circuit to start with but Arduino brings revolution in the automation industry by removing the need of developing any basic circuit. Although Atmega328 is the Microcontroller used in Arduino UNO.

Also, the burner is required to burn the program in PIC Microcontrollers, while there is no need to connect separate burner with the Arduino – simply plug it with the computer through a USB cable and start playing with it.

In this tutorial, we will thoroughly discuss what is pinMode and how to use it in the Arduino module. Let’s jump right in and explore what is this about and everything you need to know.

#### How to use pinMode in Arduino

• The Arduino Board comes with GPIO (general purpose input output) pins that can be used in two ways i.e. input, output.
• pinMode Arduino Command is used to define the operation of these Input/output pins, there are three types of modes that can be assigned using this command and are named as:
• OUTPUT.
• INPUT.
• INPUT_PULLUP.
• There are 14 digital and 6 analog pins in the module that mainly depend on the pinMode for setting up their mode of operation as an input or output.
• In this post we mainly discuss the Arduino UNO, that is based on ATmega328 microcontroller, however, you can use other modules like Pro Mini, Mega or Leonardo as per your needs and requirements. The pinMode works same in the module no matter what type of Arduino version you are using.
##### Syntax for pinMode Arduino

Here’s the syntax for our pinMode Arduino command:

pinMode(pin#, mode);

where:

• Pin defines the Arduino pin number used.
• There are three types of modes that can be assigned to pins of Arduino, which are:
• OUTPUT
• INPUT
• INPUT_PULLUP

Let’s use Pin # 8 of Arduino and assign all possible modes to it:

pinMode(8, OUTPUT);

pinMode(8, INPUT);

pinMode(8, INPUT_PULLUP);

Note:

• It is important to note that, unlike most of the functions used in the C code for Arduino module, this pinMode doesn’t store or return any value.
• You have to use any one of these three modes at a time.
##### Modes of pinMode Arduino
• In the previous section, we have discussed the basic syntax of pinMode, and I hope you have pretty much got the basic idea behind it.
• The only thing worth mentioning here is the difference between INPUT and INPUT_PULLUP.
• So, here’s a simple code where I have made Pin # 8 as an INPUT and read its status on Serial Monitor.
```int Pin = 8;

int Status = 0;

void setup()
{
Serial.begin(9600);
pinMode(Pin, INPUT);
}

void loop()
{

if(Status == HIGH)
{
Serial.println("HIGH");
}

if(Status == LOW)
{
Serial.println("LOW");
}

}```
• Let’s have a look at the Serial Monitor: • While taking the above image, Pin # 8 was in open state and we are getting just random values.
• We are getting these random values i.e. HIGH, LOW because our Pin#8 is neither connected to +5V nor GND.
• Arduino seems confused here, and we can remove this confusion by simply changing INPUT to INPUT_PULLUP.
• As we run the Serial Monitor, we will get something shown below: • You can see how we are getting HIGH value only, while the pin is still in open state.
• We can conclude, when we have nothing on our INPUT pin then INPUT_PULLUP will make the pin HIGH.
##### Difference between Read and Write

There are two ways to send or receive data. You can either define the pin as an input that helps in reading the data from an external device like sensors. Or you can define pin as an output that helps in writing and sending a command to LEDs, motors or actuators for executing the desired functions.

That’s all for today. I hope you have found this post informative as per your needs and requirements and can easily use this pinMode Arduino Command. If you are feeling skeptical or have any question, you can ask me in the comment section below. I’ll try and help you according to the best of my expertise. Thanks for reading the article.
{"ft_lang_label":"__label__en","ft_lang_prob":0.8955734,"math_prob":0.5163877,"size":4586,"snap":"2021-43-2021-49","text_gpt3_token_len":1018,"char_repetition_ratio":0.12898298,"word_repetition_ratio":0.017052375,"special_character_ratio":0.22764936,"punctuation_ratio":0.10843374,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9516525,"pos_list":[0,1,2,3,4,5,6],"im_url_duplicate_count":[null,3,null,3,null,3,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2021-10-15T21:22:30Z\",\"WARC-Record-ID\":\"<urn:uuid:412bd490-5da9-4ea2-9ff1-ea9c071d59b0>\",\"Content-Length\":\"72490\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:276855f0-0de8-4b89-a1b7-51913bc6ea11>\",\"WARC-Concurrent-To\":\"<urn:uuid:4dd03b6e-048f-475f-868d-f9634268be7a>\",\"WARC-IP-Address\":\"148.72.2.142\",\"WARC-Target-URI\":\"https://www.theengineeringprojects.com/2018/09/how-to-use-pinmode-arduino-command.html\",\"WARC-Payload-Digest\":\"sha1:SNW2DMXEQSK42E6WUFOOY6AYTQSF4MZW\",\"WARC-Block-Digest\":\"sha1:5R3BCZPD7IBGEJZCWNABWZRKNVSXG52K\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2021/CC-MAIN-2021-43/CC-MAIN-2021-43_segments_1634323583083.92_warc_CC-MAIN-20211015192439-20211015222439-00606.warc.gz\"}"}