How to use evive Digital Pins as Input Pins

evive Digital Input
About This Tutorial
This tutorial discusses how to configure the digital pins in evive as INPUT in Arduino IDE, with the help of a simple example using evive’s tactile switch.
Tutorial Info

Components Required

ImageComponentQuantityAvailable in Kit
evive1
USB A-B Cable1

Introduction

As stated in previous tutorial a digital input pin can be in either of the three states namely HIGH,LOW or Floating.

  • 0V – 1.5V: LOW
  • 3.3V – 5V: HIGH
  • 1.5V – 3.3V: floating (can either be HIGH or LOW)

In this tutorial you will be using digital pin 38 of evive as an input since it is connected to tactile switch 1 on evive. You will read the state of digital pin 38 to check when tactile switch is pressed and depending upon state of tactile switch a bar of particular color will be printed on evive screen.

Configuring a Digital Pin as an Input Pin

In evive digital I/O pins are by default set as input pins and hence they don’t need to be explicitly declared as INPUT initially in the program. But it is advised to declare each and every pin as input or output for consistency.

Digital Input pins can be configured as INPUT by using the following statement:

pinMode(pin, INTPUT);

where the pin is the digital pin number you want to initialise as input.

It is often useful to set an input pin to a known state if no external input is present. This can be done by adding a pull-up resistor (connected to +5V), or a pull-down resistor (connected to ground) on the input. A 10KΩ resistor is both a good pull-up and pull-down resistor.

digitalRead(Pin) is used for reading digital input in Arduino IDE. It returns 1 if it reads HIGH and 0 when it reads LOW.

Example: Displaying the pin state using evive’s Tactile Switch

evive Tactile Switch Pushbuttons

 

evive has two tactile switches connected to digital pin 38 and digital pin 39. When pressed, the state of the digital pin is HIGH; otherwise it is LOW.  In this Arduino IDE sketch we will read the state of digital pin 38, which is connected to tactile switch 1 and then display it on the TFT Screen.

Below is the sketch:

evive Digital Input

Share this Tutorial
Share on facebook
Facebook
Share on twitter
Twitter
Share on google
Google+
Share on pinterest
Pinterest
Share on reddit
Reddit
Share on print
Print
Related Projects & Tutorials
All articles loaded
No more articles to load
Featured Projects
Space-Battle-Game on Scratch
Space Battle

This project will show you how to make a cool space battle game on your own in PictoBlox (Scratch-based programming) and play using your Smartphone!

All articles loaded
No more articles to load

Leave a Reply

Close Menu
×

Cart