[vc_row][vc_column width=”1/1″][vc_column_text]When interfacing 3.3V devices with a 5V Arduino, the logic level needs to be shifted. Most 3.3V devices will be damaged if operated with 5V signals, while others will simply operate unreliably. The shifting can be accomplished with the careful selection of a few discrete components (see here and here), however in this post we will concentrate on a specialty IC. There is also a good bit of information available on the Arduino Playground about level shifting.
First, here are a few of the existing products that perform level shifting. Understand that these cost upwards of $8-10, were the 74LVC245 chip is about 30 cents! Some of these are unidirectional, while others are bi-directional:
- SparkFunF Logic Level Convertor
- SparkFun Level Translator Breakout
- NKC 5V to 3.3V logic level shifter board
- Adafruit 8-channel Bi-directional Logic Level Converter
- Adafruit 4-channel I2C-safe Bi-directional Logic Level Converter
This is where the inexpensive 74LVC245 comes in. It is designed to operate within -0.5 and 6.5V, which makes it perfect for the Arduino. It has 16 pins (8 pairs) for conversion in a 20-pin dip package. Unidirectional shifting can occur in either direction so it’s perfect for SPI, Serial, Parallel and other similar logic interfaces.
Using it is simple. Check out the 74LVC245 datasheet for details but essentially: connect VCC to your logic level to convert to (here: 3.3V), Wire Ground and OE (output enable) to ground. Depending on the logic level at the direction-control (DIR) pin, the device transmits data from the A pins to the B pins (DIR = Vcc), or from the B bus to the A bus (DIR = low). OE can be turned high to disable the device so the buses effectively are isolated.
Arduino/74LVC245/23K256 Wire Routing:
Arduino--74LVC2245--23K256 D13<------>A3/B3<---->6.SCK D12<----------------->2.MISO D11<------>A5/B5<---->5.MOSI D10<----------------->1.CS 3V3<------>DIR 3V3<------>Vcc 3V3<----------------->8.VCC 3V3<----------------->7.HOLD 3V3<------>[10KR]---->1.CS GND<------>GND GND<------>OE GND<----------------->4.VSS