domingo, 30 de julho de 2017

Arduino + 2.2 inches ILI9341 TFT + CD4050

Today I'm going to share with you how connect a ILI9341 TFT to an Arduino with IC CD4050 for level shifting. I will be using Arduino Nano but you can you use any other Arduino based board. 

Project Preview

Materials used:

- 2.2" ILI9341 TFT
- IC CD4050
- Arduino Nano
- Some wires

Explanation:
As mentioned before I will connect a ILI9341 TFT to Arduino and for help me doing that I will use IC CD4050 for level shifting from 5V to 3.3V. For the ones who doesn't know most Arduino boards operates with 5V logic and there are a lot of LCD like mine that only operate at 3.3V. For this situation you can do it as well with resistors and will accomplish the same result you just need to calculate the value of resistor that you need to use for level shifting from 5V to 3.3V.
CD4050
The image above represents the pinout of a CD4050 and as you can see it has 2 pins to power up the IC one for power(Vdd) and other for ground(Vss). The rest, despite of pins 13 and 16 that are NC pins, are in group of 2 pins where one is the input and the other is the output after the level shifting.

Schematic:
The image below is the schematic that I used to accomplish my objective and for better perception I created a table where you can see which Arduino pin connect LCD and where and if it goes through CD4050.

Schematic

   Arduino      CD4050   ILI9341 TFT
D4RESET
D5CS
D6D/S
3.3VxLED
D11MOSI
D12MISO
D13SCK
3.3VxVCC
Connections table
Code:
In this part we will need to add 2 external libraries to our Arduino IDE and you can download both from the links below:

- Adafruit GFX Library
- Adafruit ILI9341 Library

It is important to mention that any of the libraries that we will use were created by me. All the effort into both libraries is from  Adafruit.

After add both libraries it's time to see if everything is working. Just open Arduino IDE and go to File > Examples > Adafruit ILI9341 and open the sketch "graphicstest". Now you just need to do 2 small changes comment line 26 and uncomment line 28 and replace the LCD pins names for Arduino pin numbers that we used to connect it and you are ready to upload your sketch. You can see my final code bellow:

Demo:
After everything assemblied if everything went right you should get this:

Project Demo


Sem comentários:

Enviar um comentário