In this short instructable i will show you how i managed to use the I2C bus with this TFT LCD.
Step 1: Materials
The parts needed:
- 2.4 TFT LCD
- DS3231 for example
- some wires
- female pins
- solder and soldering iron
- a cutter
Step 2: The Display and the Preparation
The SPFD5408 tft as you know is a 240x320 pixel display that can be easily connected most of the Arduino boards and it works with most of them. It uses 8 digital , 5 analog , 2 power and 1 ground pin.
The display is very convenient in my oppinion, because just plug and use it. The only thing was disturbing me is that the display most commonly uses the one of the I2C bus line (A4) for the reset function. But after yesterday night i found myself a solution for this case.
The solution i found is that i needed to remove the reset pin of the shield and with a small wire connected it with the arduinos RESET pin. I did not mind the pin removal because the display i had was a bit defective and had to fix it before to make it usable.
Step 3: Software and the Source
Earlier when i was searching on the internet found a video on youtube. In this video was an arduino with the same display and a DS3231 RTC module. I really wanted to remake the same clock but did not have the parts to make it. So i rested the case till yesterday, when i had succeeded after 1 hour of work.
Added another sketch for McuFriend library.
The video can be found here:
Step 4: The Modification
Disclaimer: I DID NOT WRITE THE SKETCH. ONLY MODIFIED IT TO FIT MY NEEDS!!
The original setup and sketch did not work for me. So i added a few lines of code souch as theese libraries:
This library will drive our display. It has to work with ILI9320/25/28/40/41 TFT driver chips.
The next thing is to declare the analog pinout:
#define LCD_CS A3
#define LCD_CD A2
#define LCD_WR A1
#define LCD_RD A0
#define LCD_RESET 1
The Reset can be commented since we will not use the Analog 4 pin for this feature.
Adafruit_TFTLCD tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, 1);
We need 3 more lines in the void(setup):
tft.reset(); to reset the diplay
tft.begin(0x9328); set the tft lcd driver chip ID manually.
Replace the rtc.halt(false); to rtc.begin(); to start the RTC.
I had 1 compiling error: exit status 1
'drawMark' was not declared in this scope
As usual copy and paste into a new tab and no error. Problem solved!
This setup might work with the McuFriend library as well, but not sure because i have not tried.
Step 5: Assembly and the Result
The preparation and assembly was not more than 30 minutes.
So cut the shields reset pin, solder it together with Arduino reset pin. Cut down 4 or 6 female pins, use a little piece of pcb. Connect (solder) the RTC pins to the arduino board (correctly) with a few wires.
Upload the sketch and you are ready. You have a very precise Arduino clock.
Step 6: Conclusion
So it took me a while to figure this thing out(because of my stupidity), but finally it turned out in a good result.
With this simple modification now you can connect (multiple) I2C and regular sensors to the Arduino board with a "little sacrifice" and expand the possibilities of your project you want to make.I think it will be the goal for a few Arduino gadgets that i am planning with a programmer friend. The only limit is our imagination.
Step 7: Done
You are done, use it as you like!
I hope you find it useful and could help someone facing the same problem.
Have a nice day.