Using Makerhawk display with the UNO.

Hi,

I would be grateful if someone could help with this beginner project using an Anduirino Uno and a 1.44" TFT screen.

It has the ST7735 chip.

The code I am using was downloaded and appears very straightforward but I cannot get any response from the screen. :o

/*
 * Rui Santos 
 * Complete Project Details http://randomnerdtutorials.com
 */

// include TFT and SPI libraries
#include <TFT.h>  
#include <SPI.h>

// pin definition for Arduino UNO
#define cs   10
#define dc   8
#define rst  9


// create an instance of the library
TFT TFTscreen = TFT(cs, dc, rst);

void setup() {

  //initialize the library
  TFTscreen.begin();

  // clear the screen with a black background
  TFTscreen.background(0, 0, 0);
  //set the text size
  TFTscreen.setTextSize(2);
}

void loop() {

  //generate a random color
  int redRandom = random(0, 255);
  int greenRandom = random (0, 255);
  int blueRandom = random (0, 255);
  
  // set a random font color
  TFTscreen.stroke(redRandom, greenRandom, blueRandom);
  
  // print Hello, World! in the middle of the screen
  TFTscreen.text("Hello, World!", 6, 57);
  
  // wait 200 miliseconds until change to next color
  delay(200);
}

The code compiles with just 2 load image warnings regarding the SD library but I am not using those commands.

The connections are as follows:-

5v, Gnd.
SCL (SCK) to D13.
SDA to D11
RS to D8
RST to D9
CS to D10

I have swapped pins 8 & 9 around in the code to match the screen pins.

Thanks,

Martin

Life is much easier when you provide a link to the actual display you ave bought e.g. Ebay Sale

I Googled "Makerhawk 1.44" and found this

Most Red 1.44 screens are 3.3V.

The Makerhawk screen is compatible with 5V logic but you will not be able to read registers or graphics memory.

David.

Hi David,

Thanks for the reply.

Yes, that is the screen that I have.

Could you please explain what you meant by not being able to read registers or graphics memory?

All I need it to do is to display text from a midi output.

Martin

"Reading" is not relevant to your hardware. And your library does not support reading.

Sorry. It was a pointless comment from me.

Your hardware should work with the program you pasted. I suggest that you check your wiring.

The pins will line up with the Power and Analog headers. LCD_CS fits on A5 socket.
This guarantees that your wiring is "known". But you have to use the software constructor:

//TFT(cs, dc, mosi, sclk, rst);
TFT TFTscreen = TFT(A5, A3, A2, A1, A4);

Since the LED is under software control, you can switch the backlight on or off with:

    pinMode(A0, OUTPUT);
    digitalWrite(A0, HIGH);  //switch backlight on

Once the display is working, you can re-wire for hardware SPI (which will be faster)

David.

Hi David,

Thanks very much for the reply!

Still no luck, I have changed the code to this :

/*
 * Rui Santos 
 * Complete Project Details http://randomnerdtutorials.com
 */

// include TFT and SPI libraries
#include <TFT.h>  
#include <SPI.h>

// pin definition for Arduino UNO
 #define cs    A5
 #define dc    A3
 #define mosi  A2
 #define sclk  A1
 #define rst   A4
// create an instance of the library
// TFT TFTscreen = TFT(cs, dc, rst);

         //TFT(cs, dc, mosi, sclk, rst);
TFT TFTscreen = TFT(A5, A3, A2, A1, A4);

void setup() {

  //initialize the library
  TFTscreen.begin();

  // clear the screen with a black background
  TFTscreen.background(0, 0, 0);
  //set the text size
  TFTscreen.setTextSize(2);
}

void loop() {

  //generate a random color
  int redRandom = random(0, 255);
  int greenRandom = random (0, 255);
  int blueRandom = random (0, 255);
  
  // set a random font color
  TFTscreen.stroke(redRandom, greenRandom, blueRandom);

  pinMode(A0, OUTPUT);
    digitalWrite(A0, HIGH);  //switch backlight on
  
  // print Hello, World! in the middle of the screen
  TFTscreen.text("Hello, World!", 6, 57);
  
  // wait 200 miliseconds until change to next color
  delay(200);

Now I get the errors :-

Arduino: 1.8.10 Hourly Build 2019/04/18 12:33 (Windows 7), Board: "Arduino/Genuino Uno"

In file included from C:\Program Files (x86)\Microsoft Visual Studio\arduino-nightly\libraries\TFT\src/TFT.h:36:0,

from C:\Users\oem\Documents\Arduino\2nd_Display_Test\2nd_Display_Test.ino:7:

C:\Program Files (x86)\Microsoft Visual Studio\arduino-nightly\libraries\TFT\src/utility/Adafruit_GFX.h:60:3: warning: #warning "The SD library was not found. loadImage() and image() won't be supported." [-Wcpp]

#warning "The SD library was not found. loadImage() and image() won't be supported."

^

2nd_Display_Test:20:39: error: no matching function for call to 'TFT::TFT(const uint8_t&, const uint8_t&, const uint8_t&, const uint8_t&, const uint8_t&)'

TFT TFTscreen = TFT(A5, A3, A2, A1, A4);

^

In file included from C:\Users\oem\Documents\Arduino\2nd_Display_Test\2nd_Display_Test.ino:7:0:

C:\Program Files (x86)\Microsoft Visual Studio\arduino-nightly\libraries\TFT\src/TFT.h:47:3: note: candidate: TFT::TFT(uint8_t, uint8_t, uint8_t)

TFT(uint8_t CS, uint8_t RS, uint8_t RST);

^

C:\Program Files (x86)\Microsoft Visual Studio\arduino-nightly\libraries\TFT\src/TFT.h:47:3: note: candidate expects 3 arguments, 5 provided

C:\Program Files (x86)\Microsoft Visual Studio\arduino-nightly\libraries\TFT\src/TFT.h:45:7: note: candidate: constexpr TFT::TFT(const TFT&)

class TFT : public Adafruit_ST7735 {

^

C:\Program Files (x86)\Microsoft Visual Studio\arduino-nightly\libraries\TFT\src/TFT.h:45:7: note: candidate expects 1 argument, 5 provided

C:\Program Files (x86)\Microsoft Visual Studio\arduino-nightly\libraries\TFT\src/TFT.h:45:7: note: candidate: constexpr TFT::TFT(TFT&&)

C:\Program Files (x86)\Microsoft Visual Studio\arduino-nightly\libraries\TFT\src/TFT.h:45:7: note: candidate expects 1 argument, 5 provided

exit status 1
no matching function for call to 'TFT::TFT(const uint8_t&, const uint8_t&, const uint8_t&, const uint8_t&, const uint8_t&)'

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

Also, I found a page that said that on a Uno type board SDA & SCL are on analog input pins A4 and A5.

The pinouts on the display board are A5 = cs, A4 = rst, A3 = rs, A2 = sda, A1 = scl

The trouble with looking for answers on the net can be so confusing as sometimes they disagree.

Sorry to be such a nuisance but I am just a beginner at this...8-((

Martin

My apologies. The built-in TFT.h library that comes with your Arduino IDE installation is a "bit crap"

It uses a hacked elderly "Adafruit_ST7735" and a hacked elderly "Adafruit_GFX"
The "library docs" are also elderly and out of date: Arduino TFT.h documentation

The docs say there is a "software constructor" and a "hardware constructor"
The library source code only has the hardware constructor.

I strongly recommend that you Install / Update the current "Adafruit_ST7735" and the current "Adafruit_GFX" via the IDE Library Manager.
Then try the Adafruit_ST7735 library examples e.g. first with Software constructor and then with the hardware constructor.

I tried TFT and it works but only with hardware constructor. (which is why I suspect your wires)
I tried Adafruit_ST7735 and it works fine with both constructors.

David.

Hi David,

Thanks very much for the reply. >:(

I checked and I already have the latest updates for both libraries.

Sorry, but I couldn't see any info on using a hardware or software construct in the docs.

I wonder if the compiler is picking up the correct libraries as the only TFT library I can find on the pc is dated 2017!

So I will try using the adafruuit libraries instead.

No wonder there are some many problems coding the Ardurino with so many different libraries and problems with them.8-((

Martin

I gave you a link: TFT - Arduino Reference

In it you would see:

Syntax

TFT(cs, dc, rst); for using hardware SPI
TFT(cs, dc, mosi, sclk, rst); for use on any pins

However the second constructor is not actually implemented in the current library source code.

The Arduino copes with many third party libraries quite well if you use the IDE Library Manager.

Difficulties only arise when you try to install a library manually.

It is wise to select "verbose compile" i.e. via File->Preferences
This will report each library that is used with its version and where it was located on your PC. e.g.

your TFT sketch:

Using library TFT at version 1.0.6 in folder: C:\Program Files (x86)\Arduino-1.8.9\libraries\TFT 
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino-1.8.9\hardware\arduino\avr\libraries\SPI 
"C:\\Program Files (x86)\\Arduino-1.8.9\\hardware\\tools\\avr/bin/avr-size" -A "C:\\Users\\DAVIDP~1\\AppData\\Local\\Temp\\arduino_build_102085/arnak_TFT.ino.elf"
Sketch uses 6748 bytes (20%) of program storage space. Maximum is 32256 bytes.
Global variables use 110 bytes (5%) of dynamic memory, leaving 1938 bytes for local variables. Maximum is 2048 bytes.

the Adafruit_ST7735 example (using software constructor):

Using library Adafruit_ST7735_and_ST7789_Library at version 1.2.8 in folder: C:\Users\David Prentice\Documents\Arduino\libraries\Adafruit_ST7735_and_ST7789_Library 
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino-1.8.9\hardware\arduino\avr\libraries\SPI 
"C:\\Program Files (x86)\\Arduino-1.8.9\\hardware\\tools\\avr/bin/avr-size" -A "C:\\Users\\DAVIDP~1\\AppData\\Local\\Temp\\arduino_build_933973/graphicstest.ino.elf"
Sketch uses 18118 bytes (56%) of program storage space. Maximum is 32256 bytes.
Global variables use 752 bytes (36%) of dynamic memory, leaving 1296 bytes for local variables. Maximum is 2048 bytes.

You don't need to understand technicalities. Just copy-paste the last few lines from the "verbose compile" to a code window. Don't paste the whole report. It will irritate your readers. They will ask if they want more information.

You described some "compile errors"
You have never said what happens with a successful build.

I don't know your screen. The backlight might work if you leave LED pin disconnected. It is safer to connect it to a GPIO pin and switch on in setup() with pinMode() and digitalWrite()

David.

Hi David,

Just a quick update as I haven't had the chance to re-compile using the adafruit libraries as yet.

I can see that your compile is correct whilst mine is picking up the old TFT libraries, not the adafruit ones.

Hopefully, when I use the correct libraries the display should work.

Actually, I did only post the errors, not the whole compile message.8-))

When I managed previously to get a compile with just those warning I mentioned the display still did not work but I cannot remember if I had the correct libraries or not.

Perhaps I can check on my older attempts and see if that is the case.

Either way, I will try again as you have suggested, thanks for the help, back later.

Martin

Hi David,

Sorry to be a pest but I have made some changes but now get a different error.8-((

// include TFT and SPI libraries
#include <Adafruit_ST7735.h>  
#include <SPI.h>

// pin definition for Arduino UNO
 #define cs    A5
 #define dc    A3
 #define mosi  A2
 #define sclk  A1
 #define rst   A4
// create an instance of the library
// TFT TFTscreen = TFT(cs, dc, rst);
//TFT(cs, dc, mosi, sclk, rst);

void setup() {
TFT TFTscreen = TFT(A5, A3, A2, A1, A4);
  //initialize the library
  TFTscreen.begin();
pinMode(A0, OUTPUT);
    digitalWrite(A0, HIGH);  //switch backlight on
    
  // clear the screen with a black background
  TFTscreen.background(0, 0, 0);
  //set the text size
  TFTscreen.setTextSize(2);
}

void loop() {

  //generate a random color
  int redRandom = random(0, 255);
  int greenRandom = random (0, 255);
  int blueRandom = random (0, 255);
  
  // set a random font color
  TFTscreen.stroke(redRandom, greenRandom, blueRandom);

  pinMode(A0, OUTPUT);
    digitalWrite(A0, HIGH);  //switch backlight on
  
  // print Hello, World! in the middle of the screen
  TFTscreen.text("Hello, World!", 6, 57);
  
  // wait 200 miliseconds until change to next color
  delay(200);
}

Davids_Test:20:1: error: 'TFT' does not name a type

TFT TFTscreen = TFT(A5, A3, A2, A1, A4);

^

C:\Users\oem\Documents\Arduino\Davids_Test\Davids_Test.ino: In function 'void setup()':

Davids_Test:24:3: error: 'TFTscreen' was not declared in this scope

TFTscreen.begin();

^

C:\Users\oem\Documents\Arduino\Davids_Test\Davids_Test.ino: In function 'void loop()':

Davids_Test:42:3: error: 'TFTscreen' was not declared in this scope

TFTscreen.stroke(redRandom, greenRandom, blueRandom);

^

Multiple libraries were found for "Adafruit_ST7735.h"
Used: C:\Users\oem\Documents\Arduino\libraries\Adafruit_ST7735_and_ST7789_Library
Not used: C:\Users\oem\Documents\Arduino\libraries\Adafruit-ST7735-Library-master

Once uploaded there is still no reult.

Martin

Hi David,

Just to let you know that it is now working as intended. :slight_smile:

I changed back to the latest TFT library and re-compiled.

The strange thing is that the first few times I tried the compile it came up with errors regarding the

TFT TFTscreen = TFT(A5, A3, A2, A1, A4);

Also the parameters, then after leaving it for a few hours I tried again and it suddenly worked perfectly but I have no idea why?

Martin

Paste the "library and memory use" as I showed in #7.

Then we could give you an accurate answer.

Hi David,

OK, as requested :

Used: C:\Program Files (x86)\Microsoft Visual Studio\arduino-nightly\libraries\TFT
Not used: C:\Program Files (x86)\Microsoft Visual Studio\arduino-nightly\libraries\Old TFT
Using library TFT at version 1.0.6 in folder: C:\Program Files (x86)\Microsoft Visual Studio\arduino-nightly\libraries\TFT
Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Microsoft Visual Studio\arduino-nightly\hardware\arduino\avr\libraries\SPI
"C:\Program Files (x86)\Microsoft Visual Studio\arduino-nightly\hardware\tools\avr/bin/avr-size" -A "C:\Users\oem\AppData\Local\Temp\arduino_build_932907/Working_Version.ino.elf"
Sketch uses 10758 bytes (33%) of program storage space. Maximum is 32256 bytes.
Global variables use 894 bytes (43%) of dynamic memory, leaving 1154 bytes for local variables. Maximum is 2048 bytes.

Hey, at least it works,I don't know how or why?

I compiled several times with different libraries but each time I received errors, then I took the dog for a walk without shutting down the program.

Came back and tried again and suddenly it worked!

Beats me...

Martin

I strongly recommend that you NEVER use a "nightly build" of the IDE.
Likewise, I recommend that you use Boards Manager and Library Manager.
This will ensure that you get an official "Release" and should be stable.

Personally, I name the installation directory e.g. "C:\\Program Files (x86)\\Arduino-1.8.9"

This makes my library versions and IDE version obvious to a reader.

Occasionally a library author might ask you to install a Beta version.

David.

Hi David,

Thanks for the advice. :slight_smile:

As I am very new to this I didn't realise there was any difference in the builds so I just went for the latest one I could find.

I will get the correct version and re-install that.

Martin