Introduction: Arduino Tutorial for Beginners - Digital Output
In today’s instructable - "Arduino tutorial for beginners" , we explore the
digital output of a microcontroller. We expand on the built-in "blink" code example to output data to a pin.
We use the command digitalwrite and light up an external LED which creates a much more dramatic show than the onboard surface mounted LED.
The components we need for this tutorial are:
- Arduino Uno (or compatible board)
- 220 ohm resistor
- Super bright Red LED
- Hookup wire
- Computer with Arduino IDE installed and USB cable
Step 1: Wiring Up the Project
Before we start writing the code we wire up the circuit which is just a single LED with a current limiting resistor. The LED we are using is a super bright red LED that has an operating voltage of 2V and draws 15mA. The resistor value is 220 ohm which is needed to limit the current to the LED to prevent it from being damaged.
A calculation example to work out the resistor value can be found in our blog post “simple LED driver circuit” .
We use an external prototyping board to wire up the circuit as in the image above. Remembering the longest lead on the LED connects to the positive side of the circuit and the shorter lead connects to the negative side of the circuit.
Step 2: Programming the Microcontroller
Once the circuit is wired up we start coding by setting up pin 2 to be an output pin, then later in the code we can make the pin either high or low. We use a loop and blink the LED 4 times in a row using a delay of 70 milliseconds between the high and low states.
The code for this tutorial is available from here.
Using the digital output is achieved simply by setting the pin direction to be an output and then using the digitalwrite command to make the output high or low.
I hope this Tutorial has been useful to you. If you liked it please share it with a friend.
Also, I'd really appreciate it for you to join my email subscriber list where we'll keep you up to date with our latest videos, tutorials and articles relating to microcontrollers, Arduino and other electronics information. You'll also receive our free newsletter which is exclusive to our email subscribers only !
Thanks for spending your time to read this Instructable. I really appreciate it !