Digital Input/Output Pins

June 2, 2017


Under the Magic Lid of evive, there are 28 Digital 5V Input and Output (I/O) pins.

Digital I/O stands for Digital Input and Output. Digital Inputs allow a microcontroller to detect logic states, and Digital Outputs allow a microcontroller to output logic states.

Digital Input: A digital input detects if a voltage is above/below a specific threshold. If the voltage is higher than some value, evive will detect the digital input as HIGH/1. If the voltage is lower than some value, evive will detect the digital input as LOW/0.

Digital Output: A digital output allows you to control a voltage with evive. If evive instructs the output to be high, the output will produce a voltage (generally about 5 or 3.3 volts). If evive instructs the output to be LOW, it is connected to the ground and produces no voltage.

Controlling digital pins in Arduino IDE

Using the digital pin as Input

evive digital I/O pins are default assigned as inputs and hence they don’t need to be explicitly declared as input initially in the program. But it is advisable that one should declare each and every pin as input or output for consistency.

Digital Input pins can be configured as pinMode(pin, INPUT), where the pin is the digital pin number you want to initialize. Often it is useful to steer an input pin to a known state if no input is present. This can be done by adding a pull-up resistor (to +5V), or a pulldown resistor (resistor to ground) on the input. A 10K resistor is a good value for a pull-up or pulldown resistor.

If the pin is configured as INPUT_PULLUP during initialization, it inverts the behavior of the INPUT mode, where HIGH means the sensor is OFF and LOW means the sensor is ON. It is because there are 20K pull-up resistors built into the Atmega chip that can be accessed from software.

Using the digital pin as Output

Pins can be configured as OUTPUT with pinMode(pin, OUTPUT), where the pin is the digital pin number you want to initialize as output. These pins are also in a low-impedance state. This means that they can provide a substantial amount of current to other circuits. Atmega pins can source (provide positive current) or sink (provide negative current) up to 40 mA (milliamps) of current to other devices/circuits. This is enough current to brightly light up an LED (don’t forget the series resistor), or run many sensors, for example, but not enough current to run most relays, solenoids, or motors.

Short circuits on digital pins, or attempting to run high current devices from them, can damage or destroy the output transistors in the pin, or damage the entire Atmega chip. Often this will result in a “dead” pin in the microcontroller but the remaining chip will still function adequately. For this reason, it is a good idea to connect OUTPUT pins to other devices with 470Ω or 1kΩ resistors, unless maximum current draw from the pins is required for a particular application.


Using digitalWrite() function in Arduino IDE, you can write a digital pin, to a HIGH or LOW value.

If the pin has been configured as an OUTPUT with pinMode(), its voltage will be set to the corresponding value: 5V for HIGH, 0V for LOW.

If the pin is configured as an INPUT, digitalWrite() will enable (HIGH) or disable (LOW) the internal pull-up on the input pin. It is recommended to set the pinMode() to INPUT_PULLUP to enable the internal pull-up resistor.

The analog input pins can also be used as digital pins, referred to as A0, A1, etc.



Using digitalRead() function in Arduino IDE, you can read the value from a specific digital pin as HIGH or LOW.


Ensure that your child gets sufficient exposure to such futuristic technologies like AI with the help of hands-on experiences using AI kits for kids like Quarky. Sign up today to avail of special offers on this AI kit coming soon.

Controlling digital pins in PictoBlox (Scratch)

Digital Output

Set digital pin () output as () block is used for digital output on a digital pin. It sets the digital state of specified digital pin either “High” or “Low”.

  1. If the output is High, the pin will be at 5V and
  2. If the output is Low the pin will be at 0V.

set digital pin output as

The pin can be selected from the drop-down menu. This block can be used in Upload Mode as well as in Stage Mode.


Controlling Pin 13 LED using Space key. If the output is High, LED glows, and if the output is Low, LED turns off.

digital write example

Digital Read

Read status of digital pin () block available in evive extension is used for digital read in PictoBlox. It reads the state of the digital pin on evive (“High” or “Low”). If the state of the pin is “High”, it returns True, else False.

read state of digital pin

Available  pins for digital read in evive:

  • 26 digital pins available for the user (2-27)

You can choose these pins from the drop-down menu.

This block can be used in Upload Mode as well as in Stage Mode.


Displaying the state of the tactile switch in Scratch Mode.

read digital state example

Share this Documentation
Share on facebook
Share on twitter
Share on pinterest
Share on reddit
Share on print
Related Tutorials & Projects

How to use a Tactile Switch with evive

This tutorial discusses what are switches, types of switches, pull-up and pull-down resistors, and how to control the pin 13 LED on evive using a tactile switch with the help of an Arduino IDE sketch.
Featured Projects

Leave a Reply