Hi,
First time using the forum and I'm very new to Arduino - I hope that I put this in the right place . I have just bought an Arduino R4 WIFI and a 2.8" TFT LCD Module (Driver ILI9341, 240x320, SKU: MRB2801). I have verified my IDE set-up and have tried a few examples that modifies the builtin led's. They compile and downloads fine. Now I want to test the LED display. I opened the TFT example in the R4 section (IDE: file->examples->TFT->Arduino->TFTDisplaytext). I get the compile error: fatal error: avr/io.h: No such file or directory.
Searching around it seems that many people are having various problems like this, when playing with the LCD displays, but I can't find a solution. What can I do to solve the compile error ? are there other examples that will work in this set-up?
If I actually get a LCD/TFT example to compile, can that LCD display actually work with the R4? I asked ChatGPT and it suggested:
LCD Pin | Arduino Pin | Description
---------|-------------|------------
CS | 10 | Chip Select
RS | 9 | Register/Data Select
WR | 8 | Write
RD | +5V | Read (tied to VDD if not used)
RST | 7 | Reset
DB0 | 2 | Data Bit 0
DB1 | 3 | Data Bit 1
DB2 | 4 | Data Bit 2
DB3 | 5 | Data Bit 3
DB4 | A0 | Data Bit 4
DB5 | A1 | Data Bit 5
DB6 | A2 | Data Bit 6
DB7 | A3 | Data Bit 7
BL | 6 (PWM) | Backlight control (via PWM)
VDD | 5V | Power positive
GND | GND | Ground
Will this work? If not where should I look for wiring the R4 to the LCD?
Note: this library was retired and is no longer maintained.
The last time the library was updated was 2 years ago, which is long before the R4 came along. So it's not surprising at all that the library doesn't work with the R4.
The problem is the display shown is setup for a Parallel interface and the Adafruit library mentioned is setup for SPI. I don't believe they have a version that is setup for parallel, but could be wrong.
There are shields for your display for Arduino MEGA and shields for Arduino DUE (CTE).
The shields for MEGA have level converters.
But there are no shields for Arduino UNO for these displays (to my knowledge).
Guess why? the Arduino UNO doesn't have enough pins for a 16bit parallel data bus.
Some displays with 16bit data bus can be modified to use only 8 bits, but I don't see the jumpers needed for this on your picture. Maybe R4 and R5.
We might know more, if you had provided a link to the display.
-jz-
Ah ok learning here. the example is the one straight from the IDE:
/*
Arduino TFT text example
This example demonstrates how to draw text on the
TFT with an Arduino. The Arduino reads the value
of an analog sensor attached to pin A0, and writes
the value to the LCD screen, updating every
quarter second.
This example code is in the public domain
Created 15 April 2013 by Scott Fitzgerald
http://www.arduino.cc/en/Tutorial/TFTDisplayText
*/
#include <TFT.h> // Arduino LCD library
#include <SPI.h>
// pin definition for the Uno
#define cs 10
#define dc 9
#define rst 8
// pin definition for the Leonardo
// #define cs 7
// #define dc 0
// #define rst 1
// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);
// char array to print to the screen
char sensorPrintout[4];
void setup() {
// Put this line at the beginning of every sketch that uses the GLCD:
TFTscreen.begin();
// clear the screen with a black background
TFTscreen.background(0, 0, 0);
// write the static text to the screen
// set the font color to white
TFTscreen.stroke(255, 255, 255);
// set the font size
TFTscreen.setTextSize(2);
// write the text to the top left corner of the screen
TFTscreen.text("Sensor Value :\n ", 0, 0);
// ste the font size very large for the loop
TFTscreen.setTextSize(5);
}
void loop() {
// Read the value of the sensor on A0
String sensorVal = String(analogRead(A0));
// convert the reading to a char array
sensorVal.toCharArray(sensorPrintout, 4);
// set the font color
TFTscreen.stroke(255, 255, 255);
// print the sensor value
TFTscreen.text(sensorPrintout, 0, 20);
// wait for a moment
delay(250);
// erase the text you just wrote
TFTscreen.stroke(0, 0, 0);
TFTscreen.text(sensorPrintout, 0, 20);
}
They state that it is for: Arduino UNO R3 or Arduino Mega2560
...so I thought it would be good for R4 as well:
2.8'' TFT Touch Shield for your Arduino UNO R3 or Arduino Mega2560. Color TFT display with resistive touch screen and SD card port.
Technical details:
Arduino library UTFT supported (see downloads)
Screen size: 2.8" (57.6 x 47.2mm)
Screen resolution: 320 x 240 pixels
Colors: 16-bit (65,000 colors)
LCD driver: ILI9341
4-wire resistive touch screen
Supply voltage: 3.3V or 5V
Backlight: 4 white LEDs
Backlight supply voltage: 3.3V
Current consumption: 60-70mA
Size: 82.6 x 51 x 7mm
Note: This is a "maker" module for developers. It comes with no further instructions other than those you will find here on the product page. Arduino Library files can be downloaded (see under downloads).
Now I see they also have displays for "UNO" with a different pin layout :
Specifications:
Resolution: 240 RGB (H) x 320 (V)
Display driver: ILI9341 V0.7
Colour depth: 262 000 colours
System interface:
8-bits, 9-bits, 16-bits, 18-bits interface with 8080-I /8080-II series MCU
6-bits, 16-bits, 18-bits RGB interface with graphic controller
3-line / 4-line serial interface
Display mode:
Full colour mode (idle mode OFF): 262 000 colour (selectable colour depth mode by software)
Reduced colour mode (idle mode ON): 8-colour
Operating temperature: -40...85°C
Yes, that would be the best option. But you would need a library that supports it.
The one library I know that supports it is https://github.com/moononournation/Arduino_GFX.
Its Library Manager name is GFX Library for Arduino.
The data bus driver is Arduino_UNOPAR8.h. Note: This driver has been updated 2 weeks ago, not yet in the current release.
You can copy the 2 files from GitHub, or install the actual version using download and ZIP-install.
(UNO R4 MINIMA was missing in conditional compile).
No, count the pins! Your display is for some STM32 development boards. It needs an interconnection shield for MEGA.