issue104:tutoriel1
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédente | ||
issue104:tutoriel1 [2016/01/05 19:42] – fredphil91 | issue104:tutoriel1 [2016/01/12 14:22] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 8: | Ligne 8: | ||
You might want to get yourself a copy from their website (http:// | You might want to get yourself a copy from their website (http:// | ||
+ | |||
+ | Au moment où vous lirez ces lignes, ce ne sera probablement plus d' | ||
+ | |||
+ | Maintenant, revenons à ma série de programmation dans le monde réel. Cette fois-ci, nous allons commencer à vraiment contrôler les choses. J' | ||
+ | |||
+ | Durant cette série d' | ||
+ | |||
+ | Vous pouvez vous procurer un exemplaire sur leur site Web (http:// | ||
====== 2 ====== | ====== 2 ====== | ||
Ligne 26: | Ligne 34: | ||
If you have a new LED directly out of the package, you will notice that one of the leads is longer than the other. That is the Anode or the positive side. If both leads on a new device are the same length (or if you are recycling parts from an old circuit board), look for the flat edge. That will always show the Cathode or negative lead.** | If you have a new LED directly out of the package, you will notice that one of the leads is longer than the other. That is the Anode or the positive side. If both leads on a new device are the same length (or if you are recycling parts from an old circuit board), look for the flat edge. That will always show the Cathode or negative lead.** | ||
+ | |||
+ | Petit tour de nos composants | ||
+ | |||
+ | Une dernière chose avant de commencer : une discussion rapide sur certains des composants électroniques que nous utiliserons cette fois, des résistances, | ||
+ | |||
+ | Résistances | ||
+ | |||
+ | Une résistance est un dispositif qui « résiste » plus ou moins à la circulation de l' | ||
+ | |||
+ | Pour une explication plus détaillée sur les résistances, | ||
+ | |||
+ | Les LED | ||
+ | |||
+ | Les LED sont des diodes électroluminescentes et sont les remplaçantes « standard » pour les ampoules de toutes sortes. En étant attentifs dans la conception, elles dureront presque éternellement. Une LED a deux bornes/fils appelés anode et cathode. L' | ||
+ | |||
+ | Si vous sortez une nouvelle LED de sa boîte, vous remarquerez que l'un des fils est plus long que l' | ||
====== 3 ====== | ====== 3 ====== | ||
Ligne 40: | Ligne 64: | ||
So we have a switch that is connected between ground pin and GPIO pin 17 which is physical pin 11. We also have an LED connected with its cathode to GPIO pin 18 (physical pin 12) and its anode connected to a resistor that connects to the 3.3volt pin on the Pi. It is at this point that you need to make a decision. Will you reference the pins by their position on the board, or the GPIO numbers. We'll get back to that in a minute. In the meantime, here's the wiring diagram…** | So we have a switch that is connected between ground pin and GPIO pin 17 which is physical pin 11. We also have an LED connected with its cathode to GPIO pin 18 (physical pin 12) and its anode connected to a resistor that connects to the 3.3volt pin on the Pi. It is at this point that you need to make a decision. Will you reference the pins by their position on the board, or the GPIO numbers. We'll get back to that in a minute. In the meantime, here's the wiring diagram…** | ||
+ | |||
+ | Interrupteurs | ||
+ | |||
+ | L' | ||
+ | |||
+ | Notre premier projet... | ||
+ | |||
+ | Maintenant, commençons notre premier projet de construction. C'est une version électronique très simple du « hello world » (« bonjour à tous »). Nous allons connecter un interrupteur à l'une des broches GPIO et la surveiller pour visualiser l' | ||
+ | |||
+ | À droite se trouve le schéma exact avec lequel nous allons travailler. | ||
+ | |||
+ | Nous avons donc un interrupteur connecté entre la terre et la broche 17 du GPIO, qui est la broche physique 11. Nous avons aussi une LED connectée par sa cathode à la broche 18 du GPIO (broche physique 12) et dont l' | ||
====== 4 ====== | ====== 4 ====== | ||
Ligne 46: | Ligne 82: | ||
There is a short jumper going from the top ground bus to one side of the switch and the other side of the switch connects to physical pin 11 on the RPi (or GPIO pin 17). As for the LED, the Cathode is connected to the physical pin 12 on the RPi (GPIO 18) and the Anode is connected to the resistor, which in turn is connected to the lower 3.3 volt bus. Also notice that the wiring is colour coded. Red will ALWAYS (in my diagrams) be a positive voltage, Black is for ground. Any other colors will mean interconnections for data.** | There is a short jumper going from the top ground bus to one side of the switch and the other side of the switch connects to physical pin 11 on the RPi (or GPIO pin 17). As for the LED, the Cathode is connected to the physical pin 12 on the RPi (GPIO 18) and the Anode is connected to the resistor, which in turn is connected to the lower 3.3 volt bus. Also notice that the wiring is colour coded. Red will ALWAYS (in my diagrams) be a positive voltage, Black is for ground. Any other colors will mean interconnections for data.** | ||
+ | |||
+ | Vous pouvez voir sur la plaque les trois composants : l' | ||
+ | |||
+ | Il y a un cavalier court allant du bus de masse du haut à un côté de l' | ||
====== 5 ====== | ====== 5 ====== | ||
Ligne 54: | Ligne 94: | ||
Notice that the first line is commented out since I will be using the board numbering in this example, but it's there to show you how to make the call.** | Notice that the first line is commented out since I will be using the board numbering in this example, but it's there to show you how to make the call.** | ||
+ | |||
+ | Si vous avez suivi jusqu' | ||
+ | |||
+ | Comme toujours, je vais découper le code en morceaux et expliquer chacun. D' | ||
+ | |||
+ | Notez que la première ligne est commentée puisque je vais utiliser la numérotation de la carte dans cet exemple, mais elle est là pour vous montrer comment indiquer votre choix. | ||
====== 6 ====== | ====== 6 ====== | ||
Ligne 64: | Ligne 110: | ||
Finally, we use the “main loop” (shown bottom) to call the routines in the proper order and to allow us an easy way to break out of the loop by pressing the Ctrl-C key sequence.** | Finally, we use the “main loop” (shown bottom) to call the routines in the proper order and to allow us an easy way to break out of the loop by pressing the Ctrl-C key sequence.** | ||
+ | |||
+ | Les lignes 3 et 4 montrent comment définir le rôle des broches, entrée ou sortie, et si nous utilisons les résistances de rappel internes, intégrées sur le RPi, ou pas. Cette partie du code dit donc simplement d' | ||
+ | |||
+ | Notre prochaine fonction (page suivante, en haut à droite) est appelée « loop » [Ndt : boucle] et, comme son nom l' | ||
+ | |||
+ | La fonction « destroy » (ci-dessous) nettoie simplement les états des broches, afin de ne pas recevoir d' | ||
+ | |||
+ | Enfin, nous utilisons la « boucle principale » (en bas) pour appeler les routines dans le bon ordre et pour permettre de sortir facilement de la boucle en appuyant sur Ctrl-C. | ||
====== 7 ====== | ====== 7 ====== | ||
Ligne 74: | Ligne 128: | ||
Enjoy playing for now and I will see you next month.** | Enjoy playing for now and I will see you next month.** | ||
+ | |||
+ | Voilà, chargez le programme dans votre RPi et exécutez-le. Vous remarquerez que le texte "... LED Off" se répète à l' | ||
+ | |||
+ | Une autre chose à noter est que nos première et deuxième routines sont nommées « setup » et « loop ». C'est une bonne chose de garder ce format, car, quand nous arriverons à la programmation de l' | ||
+ | |||
+ | Nous allons nous arrêter ici pour ce mois-ci, car je veux laisser de la place pour les articles d' | ||
+ | |||
+ | Amusez-vous bien et je vous revois le mois prochain. | ||
issue104/tutoriel1.1452019327.txt.gz · Dernière modification : 2016/01/05 19:42 de fredphil91