Artificial Horizon display using a gyro

Trying to think of things which could slow down a lot of writes to an LCD, I see that you have quite a few pins in use, but ?no? mention of pullup resistors. Does the screen or adafruit recommend anything ? Your code looks as though it is going to presume 30k pullup built in, which might require comms to go slower than their best or be less reliable than ideal, especially if you have more than 6 inches of cabling from microcontroller to display. Various opinions abound about adding external pullup resistors from a digital pin to arduino Vcc, but I found 10kOhm or 3.3kOhm more likely to work than none at all and necessary when using a few feet of cables.

Hello, Was a copy error. There was wrong data in the file. For whatever reason. Thanks

Hello, hm work only with Arduino Duo i have Arduino Due ;o( But it is fine thx Ratlos


As you are a beginner I would start by creating a simpler sketch! For example just draw a line though the centre of the screen at an angle that is output by the sensor. You will need to store the end coordinates of the last drawn line so you can erase it by over-writing with background before drawing the new line.

Hi there ... Does anyone here? I want to run this code for horizon indicator, any other updates? Hey guys, is this topic active?

Hello Bodmer:

I have been using your TFT eSPI library with a M5stack ESP32 320x240. Works quite well ! I was wondering - why not make a artificial horizon indicator using the sprites. The pitch scale and sky+earth image would be replotted as a sprite with the wings symbol static (along with other features). What do you think ?


I did try this and it works. I will tidy up the sketch and include it as an example. I also created a simple animated compass with moving needle and dial which I might add.

Very good. Can you send me the example ? Does not matter if it is not too finished - it will a good exercise to figure out how you did this ! Thanks.

Hello BOdmer! I am using the ILI9341_due Library and the same solved problem on post #46 appears again. Can you help me? Som missed pixels in the border of moving Indicator.


Would this code be hard to convert to be used on a higher resolution display (in order to show some other values out of the AH) and with a STM32 board?

Hello Bodmer. Any chance of getting the sprite example. Confused about how the sprite programming works. Thanks

bodmer: @DrWino

I did try this and it works. I will tidy up the sketch and include it as an example. I also created a simple animated compass with moving needle and dial which I might add.

I am curious if you could provide examples to the hardware and sketch. Is there a hardware design online to the display and the wiring? Thank you in advance.

Ah, I forgot about that post. I will search out the sketches and upload it within the next 24 hours.

Here’s the compass demo, draws the compass in a Sprite then plots it to screen. Demo shows compass continuously rotating. Not sure where I put the artificial horizon demo… but I will find it.

Runs on ESP8266 or ESP32 with TFT_eSPI library. (2.03 KB)

Hi bodmer I am happy to have you. I want to make on RC SCALE HELI I did a lot of web search. Then I found your post I'm with UNO and ST7735 TFT Successful upload of demo file. It's so cool My videos Is there any ST-7789 library? I want to apply it to ST7768 IPS TFT. And I do not know how to work with the Gyro MP-6050. Please let me know if there is a solution.

Thanks Bomer

I am at same stage that Bionicsix75.

Now I would love to put the code to interconnect with the MP-6050.

Can you help, because I don’t understand that much about programming :frowning:

Has anyone figured out a ways to get this working on the 2.4 TFT lcd?

finally got my screens working thanks to David, But every time I try to edit the sketch to work on these screen all I get is tons off error messages.

Any help you be appreciated

Either post a link to the code or attach your sketch.

Good afternoon
Someone has managed to run this sketch with a GY521 MPU6050 gyroscope, an Arduino mega 2560 and a 2.4" TFT ILI9341, loaded the libraries TFT_eSPI and the TFT_ILI9341-master library, and it gives me the following error

Arduino: 1.8.10 (Windows 10), Card: “Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)”

C: -Users-SERVER LABORATORY-Documents-Arduino-libraries-TFT_eSPI / Fonts / glcdfont.c: 6:10: Fatal error:
pgmspace.h :

There is no such file or directory #include <pgmspace.h>

error compiling the Arduino Mega or Mega 2560 card

Good afternoon after updating the library TFT_ILI9341, the compilation error has been removed and it already compiles, so I was able to upload it to the Arduino, but I don't see anything, just a blank screen, without any drawing

Thanks a lot