Public post

1.1 Introduction to digital and analog pins

· 1. Know your Arduino

The following tutorials cover Arduino’s ability to sense digital and analog inputs and to respond to these inputs. The upcoming tutorials introduce techniques that you can use for these inputs. We explore the use of digital input” by using the example of a button. Furthermore, we will look at the basic technique of how to read analog values.

Digital input pins sense the presence and absence of voltage on a pin. Analog input pins measure a range of voltages on a pin. In the below picture of the Arduino Uno Board, you can see where the Digital /  Analog pins are on the board.

Figure 1, Pinout overview of an Arduino Uno board

Digital Pins

To read digital input, Arduino uses a function called digitalRead(), and it tells you if a voltage on a pin is HIGH (5volts) or LOW (0) volts. Before you can read the digital pin, you will need to tell the Arduino that the pin will be used for reading input. Therefore, we use the function pinMode(pin, input) to configure the pin.

On the Arduino Uno Board, see the picture above. There are 14 digital pins (numbered 0 to 13). Pins 0 and 1 (named RX and TX) are for serial connection and should not be used for other uses. If 14 digital pins are not enough, you can always use the analog pins as digital pins.

The digital pins on an Arduino Board have two states: off and on. If voltage is flowing, the circuit will be on. If it is not flowing, the circuit is off.

digitalWrite() is the command that tells the pin to be on or off. This can be useful, for instance, to turn an LED on or off.

Analog Pins

Unlike a digital value, which is on or off, analog values have multiple readings. For example, the volume settings on your mobile. It is not just on or off, but it can have a range of values between on and off. Arduino uses a function named analogRead to get the sensor value proportional to the voltage it sees on the analog pin.

The value will be 0 if there are 0 volts on the pin and the value will be 1023 if there are 5 volts on the pin. The value in between will be proportional. So 2.5 volts will give a value of 511. On the Arduino Uno Board, there are six analog pins (numbered from 0 to 5). Remember, these pins can also be used as digital pins. In the upcoming tutorials, we will see how we can adjust the voltage on a pin manually or by sensing the environment from the sensor.

If wiring components to your Arduino is new to you, be careful about how you connect and power the things you attach. Since a circuit must be of one voltage, you cannot connect 3volt pins with 5v pins. If the wrong voltage is applied to pins, you can damage or destroy the board. There are solutions to overcome this problem. Would you mind visiting the tutorial about logic level shifting for more detail?

Become a member

You just read a free post but there are 2 member-only posts that you don't currently have access to.

Subscribe for $14.99 monthly or $99.99 yearly.

Become a member

Comments

Comments are for members only.
Please become a member or sign in to join the conversation!

You've successfully subscribed to ArduinoPlatform
Welcome! You are now a ArduinoPlatform subscriber.
Welcome back! You've successfully signed in.
Success! You are now a paying member and have access to all content.
Success! Your billing info is updated.
Billing info update failed.