salidas digitales

Arduino digital outputs

Everything you need to know about the digital outputs

What are the digital outputs?

The digital outputs as its name suggests are “OUTPUTS” that can be programmed to have two States HIGH (with 5v) or LOW (low or 0V). I.e., on or off, if any newbie is reading this will think why learn to program Arduinos doing so and a switch? quiet this young padawan is the first step to introduce us in the programming and therefore the most basic.

Where are the digital outputs?

Simple, the digital outputs on an Arduino UNO are located on one side of it, they tend to indicate with DIGITAL (PWM) this PWM will see it later.

outputs digital one arduino
outputs digital one arduino

As we can see there are 14 (up to 13 more pin 0) outputs digital, two of them coincide with the Tx and Rx communication ports, i.e. that part of output can be used to connect the Arduino with another computer or other devices. We see that inside the box include AREF and GND these pins are not outputs or inputs the first is the reference voltage (like other things, later will be) and the other GND i.e. 0V or negative reference (being the positive 5V).

Arduino Mega digital outputs

The Arduino Mega is similar to the one but more powerful and with more connections, is that I recommend to buy, since price is much higher and any project for Arduino UNO would serve for the Mega and not vice versa.

Outputs digital arduino Mega
Outputs digital arduino Mega

In the image Note that Mega has 0 to 13 (14 in total) pin PWM (which as we have said will talk more later from them) but that can be digital, outputs has a few extra ports for communications from 14 to 21 (8 in total) also these ports can be digital and exits finally has a few pins that are exclusively digital from 22 to 53 (32 pins) so you have a total of 54 outlets Digital.

Maximum intensity of the digital outputs

The intensity is an electrical measure that indicates how much current goes through a conductor, it would indicate the number of charges (electrons) passing much more intensity more electrons circulate. Already know that the voltage is 5V when the pin is on high, and the intensity maximum is of 40 mA recommended 20mA and that the sum of all not exceed them 300mA.

This means that we do not connect anything to our Arduino, a lamp, need additional electronics that we will see in subsequent tutorials.

Programming digital outputs with Arduinos

“Hello World” or Pin13

There is a tradition in programming that is to begin studying a language programming to say “Hello World” with an Arduino that is most complicated by what the equivalent would be the Pin13 are going to create with a LED Flash programming Arduino.

Prototyping the circuit output Pin13

Our circuit below for this internship:

13 Digital output
13 Digital output

The circuit contains a resistance connected to GND by an end and to the LED by the other likewise the own LED is connected to the output of the pin13.

Resistance reduces the current flowing from the outlet itself is used to protect the LED, on many occasions to protipar you don’t need many devices still endure it is recommended.

The exit 13 Digital circuit design

This is the electronic circuit of the same, nothing if at the moment you don’t understand it, but if you follow my course I want that you gradually get to understand this kind of schemes.

Exit 13 wiring diagram
Exit 13 wiring diagram

Programming the Pin13

initial configuration of the arduino
void setup() {}
  pinMode (13, OUTPUT);
}

void loop() {}
  digitalWrite(13, HIGH);
  delay (1000);
  digitalWrite (13, LOW);
  delay (1000);
}

With this we already have our first program on Arduino, as we see consists of 2 parts the setup void and void loop. The first is the initial configuration of the Arduino, runs once (first pinMode term pin we want second configuration finish OUTPUT as output). While the second is a loop infinite, is the program in itself. In this case turn on the pin 13. wait a second (delay is expected in ms, if we change another quantity 1000 will modify the speed), we turn off the pin 13 and wait a second, start again and so until you disconnect the Arduino. digitalWrite is digital writing, the first term is the pin (13 in our case) the second HIGH or LOW, on or off respectively.

Extending to any digital output

Output pin change

We simply change the cable coming out of the led on pin 13 to any other digital output (0-12) on our plate of prototyping.

The program change

Now we change the program will add the concept of global variable:

Global variables
int pinLED = 12;
initial configuration of the arduino
void setup() {}
  pinMode (pinLED, OUTPUT);
}

void loop() {}
  digitalWrite(pinLED, HIGH);
  delay (1000);
  digitalWrite (pinLED, LOW);
  delay (1000);
}

At the beginning of the program, we declare a variable type int (integer positive or negative numbers no decimals) and give the value you want in this case 12. During the entire program ledPin will be equal to 12 (it can be, but in this case we have not done). because we have made this change?. Right now the program serves to blink pin 12, if we wish to change single PIN at first int pinLED = 11 or any other value, if we use the program enterior of pin 13 should change all the 13 new pin, so it is more comfortable on the other hand increases when the complexity of the program is more easy to see words as ledPIN , Temperature, PotenciaMotor… than a number.

Links external

Pin Digital Arduino (English)

Repository on GitHub of Arduino digital outputs

GitHub Arduino digital outputs
GitHub Arduino digital outputs

Freelance Arduino projects.

Exhibitor Arduino

If you wish to buy an Arduino for this or other projects click here or on the image.

Arduino genuine one
Genuine Arduino

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: