issue111:python
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
issue111:python [2016/07/31 14:23] – créée auntiee | issue111:python [2016/08/24 11:18] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | Last month, we worked with the DS18B20 Temperature Sensor. This month we will start to interface a 16x2 LCD display to show our temperatures. Don’t tear down your setup, but make sure you have enough room to mount the display on your breadboard. You’ll need about 32 pinholes for the length of the device and 16 for the pins to connect to. You will have only three pinholes left if you mount the display at the bottom of the vertical holes, so you will need to use some jumpers to connect the bottom verticals to the top verticals. | + | **Last month, we worked with the DS18B20 Temperature Sensor. This month we will start to interface a 16x2 LCD display to show our temperatures. Don’t tear down your setup, but make sure you have enough room to mount the display on your breadboard. You’ll need about 32 pinholes for the length of the device and 16 for the pins to connect to. You will have only three pinholes left if you mount the display at the bottom of the vertical holes, so you will need to use some jumpers to connect the bottom verticals to the top verticals. |
Of course, the 16x2 display has 16 characters on two rows. The backlight comes in many colours. I chose a blue one. We can address each of the 32 character positions individually, | Of course, the 16x2 display has 16 characters on two rows. The backlight comes in many colours. I chose a blue one. We can address each of the 32 character positions individually, | ||
Ligne 6: | Ligne 6: | ||
• 10K Potentiometer | • 10K Potentiometer | ||
• 16x2 LCD Display | • 16x2 LCD Display | ||
- | • Many breadboard jumpers, Male to Male and 8 Male to Female | + | • Many breadboard jumpers, Male to Male and 8 Male to Female** |
- | By the time you are done, the wiring diagram (and the resulting board) will look like a bit of a rat’s nest, but go slowly – make sure you have the wiring correct. | + | Le mois dernier, nous avons travaillé avec le capteur de température DS18B20. Ce mois-ci, nous commencerons par interfacer un afficheur LCD 16x2 pour montrer nos températures. Ne défaites pas votre montage, mais assurez-vous que vous avez assez de place pour monter votre afficheur sur la plaque d' |
+ | |||
+ | Bien sûr, l' | ||
+ | |||
+ | Nous ferons 8 connexions au RPi, en plus des trois que nous utilisions le mois dernier pour le capteur de température. Ce mois-ci, nous aurons besoin des composants supplémentaires suivants : | ||
+ | • un potentiomètre de 10k ; | ||
+ | • un afficheur LCD 16x2 ; | ||
+ | • de nombreux cavaliers pour la plaque d' | ||
+ | |||
+ | **By the time you are done, the wiring diagram (and the resulting board) will look like a bit of a rat’s nest, but go slowly – make sure you have the wiring correct. | ||
As you can see in the graphic above, it’s pretty crazy, so I’ll lay out all the wiring for you in text. | As you can see in the graphic above, it’s pretty crazy, so I’ll lay out all the wiring for you in text. | ||
Ligne 14: | Ligne 23: | ||
First, you will need to put a jumper between the two horizontal busses on both the top and bottom. That way, you’ll have power and ground on both busses. I chose to do it on the left side, but you can put it anywhere that is convenient for you. The next thing to do is to wire in the potentiometer. One side (it doesn’t matter which) needs to go to ground and the other side to our 5 volt supply. The center contact (the wiper) will wire to pin 3 of the LCD display. This controls the contrast, so you can control how bright the characters appear. You should already have 5 volts to the board, as well as ground, from last month. | First, you will need to put a jumper between the two horizontal busses on both the top and bottom. That way, you’ll have power and ground on both busses. I chose to do it on the left side, but you can put it anywhere that is convenient for you. The next thing to do is to wire in the potentiometer. One side (it doesn’t matter which) needs to go to ground and the other side to our 5 volt supply. The center contact (the wiper) will wire to pin 3 of the LCD display. This controls the contrast, so you can control how bright the characters appear. You should already have 5 volts to the board, as well as ground, from last month. | ||
- | On the display, connect pin 1 to ground and pin 2 to the +5 volt buss. That makes three connections out of the twelve we need. Pin 6 of the display goes to pin 22 of the RPi. This is the Enable pin. Pin 5 on the display goes to ground, and pin 4 to pin 27 on the RPi. We are up to 6 connections so far. That makes us halfway there. Because we have to use pin 4 for our sensor, we can’t control the backlight. | + | On the display, connect pin 1 to ground and pin 2 to the +5 volt buss. That makes three connections out of the twelve we need. Pin 6 of the display goes to pin 22 of the RPi. This is the Enable pin. Pin 5 on the display goes to ground, and pin 4 to pin 27 on the RPi. We are up to 6 connections so far. That makes us halfway there. Because we have to use pin 4 for our sensor, we can’t control the backlight.** |
- | Now we will work backwards from pin 16. Pin 16 goes to ground, and pin 15 to +5v. Pin 15 is actually the backlight voltage on mine. If you find the display too bright, you could put the wiper of another potentiometer connected between +5v and ground and control the display backlight. | + | Une fois terminé, le schéma de câblage (et en vrai sur la plaque) ressemblera un peu à un plat de nouilles, mais allez-y lentement, assurez-vous de faire le câblage correctement. |
+ | |||
+ | Comme vous pouvez le voir sur le schéma ci-dessus, c'est plutôt horrible ; aussi, je vais vous détailler tout le câblage dans un texte. | ||
+ | |||
+ | D' | ||
+ | |||
+ | Sur l' | ||
+ | |||
+ | **Now we will work backwards from pin 16. Pin 16 goes to ground, and pin 15 to +5v. Pin 15 is actually the backlight voltage on mine. If you find the display too bright, you could put the wiper of another potentiometer connected between +5v and ground and control the display backlight. | ||
Now for the data lines. There are actually 8 data lines, but thankfully, we will be using only 4. Pins 11 to 14 are D4, D5, D6 and D7 (counting from 0). Here is the connection list. | Now for the data lines. There are actually 8 data lines, but thankfully, we will be using only 4. Pins 11 to 14 are D4, D5, D6 and D7 (counting from 0). Here is the connection list. | ||
+ | |||
Now everything is hooked up, so we will continue with some sample code to test the display. But we need to get the Adafruit python library for LCDs. In a terminal window, type the following... | Now everything is hooked up, so we will continue with some sample code to test the display. But we need to get the Adafruit python library for LCDs. In a terminal window, type the following... | ||
+ | |||
+ | git clone https:// | ||
+ | |||
+ | cd Adafruit_Python_CharLCD | ||
+ | |||
+ | sudo python setup.py install | ||
+ | |||
+ | cd examples** | ||
+ | |||
+ | Maintenant, nous allons travailler en descendant depuis le picot 16. Le picot 16 va à la masse, et le picot 15 au +5 V. Sur le mien, le picot 15 est en fait le voltage du rétro-éclairage. Si vous trouvez l' | ||
+ | |||
+ | Maintenant, les lignes de données. Il y a réellement 8 lignes de données, mais, heureusement, | ||
+ | |||
+ | Maintenant tout est connecté et nous continuerons avec un échantillon de code pour tester l' | ||
git clone https:// | git clone https:// | ||
Ligne 29: | Ligne 61: | ||
cd examples | cd examples | ||
- | Now load char_lcd.py into your favorite editor. Or, you could type it in from the previous page. | + | **Now load char_lcd.py into your favorite editor. Or, you could type it in from the previous page. |
Ignore the backlight messages, but you should see... | Ignore the backlight messages, but you should see... | ||
Ligne 44: | Ligne 76: | ||
Here is the modified program from last month that includes snippets from this example (top right) from Adafruit. (New code is in bold.) | Here is the modified program from last month that includes snippets from this example (top right) from Adafruit. (New code is in bold.) | ||
- | That’s about it for this month. Next month we will look at changing out our regular 16x2 display for a 16x2 I2C display (which uses only 2 lines for data and all control, and 2 lines for power.) We will also discuss the different ways of using serial communication for interfacing displays and other devices. Until then, have fun! | + | That’s about it for this month. Next month we will look at changing out our regular 16x2 display for a 16x2 I2C display (which uses only 2 lines for data and all control, and 2 lines for power.) We will also discuss the different ways of using serial communication for interfacing displays and other devices. Until then, have fun!** |
+ | |||
+ | Maintenant, chargez char_lcd.py dans votre éditeur favori. Ou vous pouvez le copier à la main de la page précédente. | ||
+ | |||
+ | Ignorez les messages de rétro-éclairage ; mais vous devrez voir : | ||
+ | |||
+ | Hello World! (Bonjour le monde) | ||
+ | Show Cursor_ (curseur visible) | ||
+ | Blink Cursor_ (curseur clignotant) | ||
+ | Scroll (right and left) (déplacement, | ||
+ | Flash backlight in 5 seconds... (rétro-éclairage flashant dans 5 secondes) | ||
+ | Goodbye! (Au revoir !) | ||
+ | |||
+ | Si tout a bien fonctionné, | ||
+ | |||
+ | Voici le programme du mois dernier, modifié, qui inclut des bribes de code venant de cet exemple (en haut à droite) d' | ||
+ | |||
+ | C'est tout pour cette fois. Le mois prochain, nous examinerons le remplacement de notre afficheur 16x2 classique par un afficheur IC2 16x2 (qui n' | ||
issue111/python.1469967809.txt.gz · Dernière modification : 2016/07/31 14:23 de auntiee