Ceci est une ancienne révision du document !
Several months ago, I bought a couple of cheap screens for use with my Arduino. I got them from Banggood for a couple of pounds/dollars each. One was a Nokia 5110 style screen, the other was a 1.8” Color TFT screen which does 160 x 128 pixels: http://www.banggood.com/1_8-Inch-Serial-SPI-TFT-LCD-Display-Module-With-Power-IC-SD-Socket-p-909802.html It’s the color screen I’d like to discuss this month. Coming from cheapo sellers such as Banggood (or if you use some eBay/Amazon sellers), most stuff has scant information. Having scoured around Banggood comments, and on Google, I eventually managed to find the right library, adjustments, and code, to get my screen to work. First, the libraries. You can grab them (and some documentation) from: http://devacron.com/QDtech_TFT180A_S6D02A1%20LCD%20Module.zip
Il y a plusieurs mois, j'ai acheté une paire d'écrans bon marché pour les utiliser avec mon Arduino. Je les ai obtenu chez Banggood pour 2 livres/dollars chacun. L'un est un écran du style du Nokia 5110, l'autre est écran couleur TFT de 1,8“ avec 160×128 pixels : http://www.banggood.com/1_8-Inch-Serial-SPI-TFT-LCD-Display-Module-With-Power-IC-SD-Socket-p-909802.html
C'est l'écran couleur que j'aimerais vous présenter ce mois-ci.
D'abord, les bibliothèques. Vous pouvez les récupérer (avec un peu de documentation) sur : http://devacron.com/QDtech_TFT180A_S6D02A1%20LCD%20Module.zip
To install the libraries: go to the Arduino programming interface; in the menu, go to Sketch > Import Library > Add Library; and point it to the ZIP file that you downloaded. If you go to File > Examples > TFT > Arduino, you’ll see some example code. Some screens that I’ve bought in the past (such as the Nokia 5110) come with the header pins (the pins you stick into the breadboard) as a separate piece that you need to solder on. This isn’t much of a problem, but this color screen came with the header pins attached. So, plug the screen into your breadboard, wire up your Arduino 5V and GND pins to the relevant strips on your breadboard, and let’s get the screen on. First, the important part that’s not mentioned in most documentation: you must use 1K resistors on all the data lines. In other words, all but the 5V, BL, and GND. You also need to connect the BL pin to the 5V line.
Now, with it all wired up, we need some code. This code I’m going to show you is really for next month (where I’ll add an ultrasonic sensor), but it is still a good foundation of how to get the screen to show you something. Code is at: http://pastebin.com/UYQe58xB A couple of quick pointers and notes on the code: • You can ignore the <NewPing.h> – that’s for next month. Also ignore the #define lines and the NewPing line below them. • The commented lines (beginning with ) are the pinouts for the screen. • The extern lines are for the font(s) used on the screen. SmallFont() is about the best, but you can chop and change between it and, say, BigFont() in the code. The setup() is exclusively for the screen. All commands with myGLCD are for the screen. Let’s look at a couple of them: We begin by initialising the screen: myGLCD.InitLCD(); Telling it we want to use the small font: myGLCD.setFont(SmallFont); Next, we clear the screen: myGLCD.clrScr(); Pick a color to use in the next command: myGLCD.setColor(255, 255, 255); A very important thing to note here is with the color values. Normally you would use RGB, but this screen uses BGR. Using 255,0,0 won’t get you red, it’ll get you blue. Then we print ‘Distance in cm:’ one pixel down and in the center of the screen. myGLCD.print(“Distance in cm:”,CENTER, 1); The rest of the code is mainly for the sonar ping and displaying the distance, but we’ll get to that next month. For now, feel free to read through the PDF’s in the ZIP you downloaded. It has some interesting commands in there that will let you draw shapes and even set the screen display to landscape/portrait mode.**