issue95:arduino
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
issue95:arduino [2015/04/07 17:53] – créée auntiee | issue95:arduino [2015/04/14 15:37] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | 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/ | + | **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/ |
It’s the color screen I’d like to discuss this month. | It’s the color screen I’d like to discuss this month. | ||
Ligne 5: | Ligne 5: | ||
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, | 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, | ||
- | First, the libraries. You can grab them (and some documentation) from: http:// | + | First, the libraries. You can grab them (and some documentation) from: http:// |
- | 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. | + | Il y a plusieurs mois, j'ai acheté une paire d' |
+ | |||
+ | C'est l' | ||
+ | |||
+ | Venant de vendeurs très bas de gamme tel Banggood (ou certains vendeurs sur eBay ou Amazon), la plupart des achats ne sont pas accompagnés d'une vraie notice. Ayant lu tous les commentaires sur Banggood et sur Google, j'ai enfin réussi à trouver la bonne bibliothèque, | ||
+ | |||
+ | D' | ||
+ | |||
+ | **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. | 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: | + | First, the important part that’s not mentioned in most documentation: |
+ | Installer les bibliothèques : allez sur l' | ||
+ | Certains des écrans que j'ai achetés dans le passé (tel que le Nokia 5110) arrivaient avec des connecteurs (les picots que vous branchez dans la plaque d' | ||
- | 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. | + | Pour commencer, une chose importante qui n'est pas bien documentée : vous devez utiliser des résistances de 1k sur toutes les lignes de données. Autrement dit, toutes sauf les 5V, BL et GND. Vous devez aussi relier le picot BL à la ligne 5V. |
+ | |||
+ | **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:// | Code is at: http:// | ||
Ligne 22: | Ligne 34: | ||
• You can ignore the < | • You can ignore the < | ||
• The commented lines (beginning with //) are the pinouts for the screen. | • 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 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: | + | Maintenant que tout est câblé, nous avons besoin de code. Le code que je veux vous montrer, ce sera plutôt pour le mois prochain (où j' |
+ | |||
+ | Le code est sur : http:// | ||
+ | |||
+ | Quelques précisions et remarques sur ce code : | ||
+ | • Vous pouvez ignorer le < | ||
+ | • Les lignes de commentaires (commençant par //) sont sur les branchements de l' | ||
+ | • Les lignes extern sont pour les polices utilisées avec l' | ||
+ | |||
+ | **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: | We begin by initialising the screen: | ||
Ligne 42: | Ligne 63: | ||
myGLCD.setColor(255, | myGLCD.setColor(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. | + | 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. | + | La partie setup() est exclusivement pour l' |
+ | |||
+ | Nous commençons par initialiser l' | ||
+ | |||
+ | myGLCD.InitLCD() | ||
+ | |||
+ | et lui dire que nous voulons utiliser une petite police : | ||
+ | |||
+ | myGLCD.setFont(SmallFont). | ||
+ | |||
+ | Ensuite, nous effaçons l' | ||
+ | |||
+ | myGLCD.clrScr() | ||
+ | |||
+ | et choisissons une couleur à utiliser avec la commande suivante : | ||
+ | |||
+ | myGLCD.setColor(255, | ||
+ | |||
+ | Les valeurs de couleurs sont un point vraiment important à noter ici. Normalement, | ||
+ | |||
+ | **Then we print ‘Distance in cm:’ one pixel down and in the center of the screen. | ||
myGLCD.print(" | myGLCD.print(" | ||
Ligne 50: | Ligne 91: | ||
The rest of the code is mainly for the sonar ping and displaying the distance, but we’ll get to that next month. | 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/ | + | 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/ |
+ | |||
+ | Ensuite, nous affichons « Distance in cm: » (Distance en cm : ), en descendant d'un pixel et centré sur l' | ||
+ | |||
+ | myGLCD.print(" | ||
+ | |||
+ | Le reste du code est principalement pour la détection sonar et l' | ||
+ | |||
+ | Pour le moment, n' |
issue95/arduino.1428422035.txt.gz · Dernière modification : 2015/04/07 17:53 de auntiee