Connecting the Digital Pin on Arduino

In this article, we will discuss how to connect a digital pin on an Arduino board and program it to make an LED blink. We will start by choosing the digital pin D13, which is also the internal LED on the board.

Defining the Digital Pin as Output

Once we have chosen the digital pin, we need to define it as an output in the setup routine. This means that we are instructing the Arduino to use this pin as an output. We also need to define a field with the value 13, as our LED is connected to this pin.

Creating the Blinking Program

In the loop, we will set the pin to HIGH and then to LOW in an alternating manner. We will also add a small delay of 500 milliseconds between each change. This will make the LED blink. Once we have written the program, we can upload it to the Arduino board using the upload button on the top left corner of the Arduino IDE. Make sure to select the correct microcontroller before uploading.

Adding a Second LED

In the second example, we will add a second LED and program it to blink alternately with the first LED. Disconnect the Arduino from the computer and connect the second LED, for example, a green LED, to digital pin D8. Just like the blue LED, make sure to use a resistor and connect it to the ground pin (GND) on the Arduino.

Expanding the Program

To include the second LED in the program, go back to the Arduino IDE and add a second field for the green LED. Rename the field for the blue LED to differentiate between the two. Now you can write the code to make both LEDs blink alternatively. Once the code is ready, reconnect the Arduino to the computer and upload the program. You will now see both the blue and green LEDs blinking.

With this tutorial, you have successfully connected and programmed LEDs to blink using the digital pins on the Arduino board. Feel free to experiment with different LEDs and pins to create your own LED patterns and effects.

Share.
Exit mobile version