How to interface 3.3V Digital I/O

About This Tutorial
This tutorial discusses the use of bidirectional logic shifter as 3.3V digital input and output with the help of an Arduino IDE sketch.
Tutorial Info
Programming Platform:
Difficulty:
Estimated Time (hrs):
2

Components Required

ImageComponentQuantityAvailable in Kit
evive1
USB A-B Cable1

Introduction

evive has two bidirectional logic level shifters which are accessible from digital pin 36 and 37 in Arduino IDE. The flow of direction is controlled by digital pin 33. evive uses 74LVC245 for level shifting.

Digital pins 36 and 37 are directly connected to the level shifter. Level shifter takes 5V input and output from the digital pins and converts them to 3.3V I/O. These 3.3V I/O pins are shown in the figure below. If you want to give 3.3V output from these pins, then you must configure digital pins 36 and 37 as output pins in Arduino IDE. You can use the IO3V3 pins as input pins anytime without configuring them as INPUT or OUTPUT. You must, however, change the state of digital pin 33 to LOW before using them as input pins.

evive 3.3V Input Output

 

Programming in Arduino IDE:

By changing the state of digital pin 33, you can change the characteristics of the logic shifter either as input or output. If the state of digital pin 33 is HIGH, then the IO3V3 pins act as output pins; but if the state is LOW, then they act like input pins.

evive Alert
The digital pin 33 should always be configured as output pins.

Example

Below is the Arduino IDE sketch showing how to use the  bidirectional logic shifter as 3.3V digital input and output:

[pastacode lang=”c” manual=”%2F*%0AThis%20code%20demonstrates%20the%20use%20of%20bidirectional%20logic%20shifter%20as%203.3V%0Adigital%20output%20and%20input.%20Connect%20the%20positive%20pin%20of%20the%20LED%20to%20IO3V3%0Apin%201%20and%20negative%20pin%20to%20the%20GND.%0AThis%20code%20will%20link%20the%20LED%20using%203.3V%20digital%20output%20as%20well%20as%20read%20the%20state%20of%20LED%20and%20IO3V3%20pin%202.%0A%0AModified%20by%20Pankaj%20Kumar%20Verma%0Aon%2018%20Jan%2C%202017%0A*%2F%0A%0A%23include%20%3Cevive.cc%3E%0Avoid%20setup()%20%7B%0ApinMode(IO3V3_PIN1%2C%20OUTPUT)%3B%20%2F%2F%20Configure%20digital%20pin%2036%20as%20output%0ApinMode(LEVELSHIFTER_DIR%2C%20OUTPUT)%3B%20%2F%2F%20Configure%20digital%20pin%2033%20as%20output%0ApinMode(IO3V3_PIN2%2C%20INPUT)%3B%20%2F%2F%20Configure%20digital%20pin%2037%20as%20input%0A%0ASerial.begin(9600)%3B%20%2F%2F%20Start%20Serial%0ASerial.println(%22Start%22)%3B%0A%7D%0A%0Avoid%20loop()%20%7B%0AdigitalWrite(LEVELSHIFTER_DIR%2C%20HIGH)%3B%20%2F%2F%20Logic%20shifter%20work%20as%20output%0AdigitalWrite(IO3V3_PIN1%2C%20LOW)%3B%0Adelay(1000)%3B%0A%0AdigitalWrite(LEVELSHIFTER_DIR%2C%20LOW)%3B%20%2F%2F%20Logic%20shifter%20work%20as%20input%0ASerial.println(digitalRead(IO3V3_PIN2))%3B%0ASerial.println(digitalRead(IO3V3_PIN1))%3B%0A%0AdigitalWrite(LEVELSHIFTER_DIR%2C%20HIGH)%3B%20%2F%2F%20Logic%20shifter%20work%20as%20output%0AdigitalWrite(IO3V3_PIN1%2C%20HIGH)%3B%0Adelay(1000)%3B%0A%0AdigitalWrite(LEVELSHIFTER_DIR%2C%20LOW)%3B%20%2F%2F%20Logic%20shifter%20work%20as%20input%0ASerial.println(digitalRead(IO3V3_PIN2))%3B%0ASerial.println(digitalRead(IO3V3_PIN1))%3B%0A%7D” message=”3.3V Digital Input-Output Example” highlight=”” provider=”manual”/]

This Helped
This didn't help
Share this Tutorial
Facebook
Twitter
Google+
Pinterest
Reddit
Print
Related Tutorials
Featured Projects

Leave a Reply

Close Menu
×

Cart