How to program atmega2560 r3 with 3,5"tft for multiple pictures

Hello, i am completly new to Arduino,
And now i have a question

How do i program a Atmega2560 R3 with a 3,5"tft on top with sd card reader to display a picture and with activating a input pin to go to the next picture and wenn at the end of the list go back to the first picture ( for example i have 7 pictures)

And is it possible to use the input pin with a GND signal

Your help would be appreciated

With kind regards,
Gerard

That's quite ambitious for someone new to Arduino.
What other programming experience do you have?

Siemens Logo

This is a project i need for my hobby RC Trucks

@gerard1973, welcome.

Your topic has been moved to a more suitable location on the forum. Installation and Troubleshooting is not for problems with (nor for advise on) your project :wink: See About the Installation & Troubleshooting category.

I don't know much about TFT but it sounds feasable. The reading of a pin to cycle through something is reasonably easy.

Do you already have some stuff? Or do you still have to buy?

I have atmega 2560 R3
And 3,5"tft 320X480 which uses ILI9486 driver

Please post a link to the actual display that you have bought. e.g. Ebay sale page.

Yes, it is possible to do what you want. But we need to identify your display so that we can advise library, wiring, ...

David.

Here is the link to the display

https://nl.aliexpress.com/item/32609807497.html?spm=a2g0s.9042311.0.0.45544c4dOJRGJP

That is a regular Mega2560 Shield. You just plug it in and go.
Install the TFT_HX8357 library from Bodmer. i.e. https://github.com/Bodmer/TFT_HX8357
Edit the User_Setup.h file to select ILI9486
Run all the library examples.

I don't think it is available through the IDE Library Manager. You will have to install from a ZIP.

You can access the unused pins with a short piece of angle header strip. Connect your push-button between an unused GPIO pin and GND.

David.

Thanxs for this

I will try

I have tried this and i can see the picture building on the side line of the picture but it does not come on the screen
The examples are working as they should be nice in the middle and good
But wenn i try my BMP picture 320x480 24 bit colour it only moves on the side of the picture (3mm) and thats it

someone any suggestions?

Has anyone seen your code?

// On the SD card use 24 bit color BMP files (be sure they are 24-bit!)
// There are examples images in the sketch folder.

// MS Paint can be used to crop, resize and flip and save images in 24bit BMP format

// Updated 31/3/15 to include new drawRAW() function that draws raw 16 bit images.
// Raw images are created with UTFT library tool (libraries\UTFT\Tools\ImageConverter565.exe)
// Save as .raw file as this can be easily piped to the TFT pushColors() function
// without any tedious byte swapping etc
 
#include <TFT_HX8357.h>        // Hardware-specific library
TFT_HX8357 tft = TFT_HX8357(); // Invoke custom library

// SD Card library, comment out next line if the SdFat library is used
#include <SD.h>

// We can use the SdFat library instead and it will be a bit faster, uncomment next 2 lines
//#include <SdFat.h>           // Use the SdFat library for the Due
//SdFat SD;                    // Permit SD function call compatibility with no sketch changes :-)

// SD chip select
#define SDC_CS 53

// These are used when calling drawBMP() function
#define BU_BMP 1 // Temporarily flip the TFT coords for standard Bottom-Up bit maps
#define TD_BMP 0 // Draw inverted Top-Down bitmaps in standard coord frame

/***************************************************************************************
** Function name:           setup
** Descriptions:            To set things up
***************************************************************************************/

void setup()
{
  Serial.begin(38400); // For debug messages
  delay(4000);

  tft.init(); // Initialise the display (various parameters configured)
  
  Serial.print(F("Initialising SD card..."));
  if (!SD.begin(SDC_CS)) {
    Serial.println(F("failed!"));
    //return;
  }

  Serial.println(F("Here we go..."));

}

/***************************************************************************************
** Function name:           loop
** Descriptions:            Infinite loop
***************************************************************************************/

void loop()
{
  // Standard BMP files are usually stored with a raster scan of pixel values from bottom up
  // File names MUST use the 8.3 file name format (8 chars + . + any 3 extension letters)
  // By convention bitmap files end in .bmp
  // Bit maps MUST be in 24 bit colout (not 16 or 8 bit greyscale)
  
  // Landscape mode
  tft.setRotation(3);
  tft.fillScreen(TFT_BLACK);
  
  // Draw bmp image top left corner at x,y = 0,0
  // Image must fit (one day I will add clipping... but it will slow things down)
  drawBMP("verbod1.bmp", 0, 0, BU_BMP);

  delay(2000);

  
}

verbod

This is the picture i use ( this is a PNG file but i use the BPM version of it)

It is always WISE to run the library examples first. Report any problems.

quote by name e.g. examples/Draw_SDCard_Bitmap

Then you can replace the example image with your BMP file.
Copy-paste your changed line(s) from Draw_SDCard_Bitmap.ino
Attach/upload your actual BMP file with editor icon #7

Then we can replicate your program / problem.

I don't want to guess what changes you have made. I just want you to tell me e.g. Draw_SDCard_Bitmap.ino

  //drawBMP("480Mouse.bmp", 0, 0, BU_BMP);
  drawBMP("verbod1.bmp", 0, 0, BU_BMP);

David.

I opened your verbod1.png in IrfanView. It was reported as 480x480 x 8BPP (i.e. 256 colour palette)
If I save it as a BMP, IrfanView saves as a 256 colour palette BMP file. Bodmer does not support this particular BMP format.

If I convert it to 24bit colour (i.e. 16M colours) IrfanView will save as a regular 24-bit BMP.

Since your screen is 480x320 the BMP is not going to fit. But I suspect that the example sketch will still "work".

However it seems wiser to just scale it as a 320x320 x 24BPP image and save the BMP.

So you can see how important it is to attach the appropriate file.
Note that the Forum does not accept BMP files. So I have put them into a ZIP file.

Untested on real hardware. I am not going to dig out a suitable screen unless you provide quoted examples with accurately copy-pasted edit lines.

David.

verbod1.zip (19.2 KB)

i have tried to upload the picture you send me and it works GREAT.

Thanxs for the quick reaction

I am pleased that you have got it working now.

What was your original problem? Was it the wrong format BMP ?
Just compare file sizes with the 480x480.bmp that I attached.

David.

Yes my original BMP size was wrong

But now i need to find out how to switch between pictures with a signal that goes to GND
I have 12 pictures on the card and i want them to change from picture 1 and then with a GND signal to go to picture 2 and so on

and wenn it reeches picture 12 it goes back to picture 1 on the next GND signal