| Ligne 51 : |
Ligne 51 : |
| | {{traduction}} | | {{traduction}} |
| | | | |
| − | The goal is to use a push button to switch voltage on and off for a GPIO pin, thus making the pin's reading change in our code when we press the button.
| + | Le but est d'utiliser un bouton poussoir pour changer la tension (niveau haut / niveau bas) sur une broche du GPIO, nous permettant ainsi de lire le changement sur la broche à l'aide de notre programme. |
| | | | |
| − | When a GPIO pin is in input mode the pin is said to be '''floating''', meaning that it has no fixed voltage level. That's no good for what we want, as the pin will randomly float between {{fname|HIGH}} and {{fname|LOW}}. For this job, we need to know categorically whether the button is up or down, so we need to fix the voltage level to {{fname|HIGH}} or {{fname|LOW}}, and then make it change only when the button is pressed.
| + | Lorsqu'une broche du GPIO est en mode d'entrée (''Input'') sont état est dit 'flottant', signifiant que nous devons fixer par nous même son niveau logique (soit le niveau de tension haut ou niveau de tension bas). Dans notre cas de figure, cette état 'flottant' de la broche ne fait pas notre affaire car, justement, en état flottant la lecture n'est pas fiable... nous lirons des valeurs aléatoires entre {{fname|HIGH}} (haut) et {{fname|LOW}} (bas). Pour ce qui nous intéresse, nous avons besoin de savoir exactement si le bouton est enfoncé ou non. Nous avons donc besoin de forcer la tension soit au niveau {{fname|HIGH}} (haut) ou {{fname|LOW}} (bas) -ET- de changer cette tension uniquement si le bouton est pressé. |
| | | | |
| − | The flight hardware buttons are all wired in a '''pull up''' configuration, which means we pull the GPIO to {{fname|HIGH}} and only short it to {{fname|LOW}} when we press the button.o
| + | Le matériel de vol du boîtier Astro-Pi tous les boutons sont raccordé dans une configuration '''pull up''', ce qui signifie que la tension du GPIO est artificiellement placée au niveau haut ({{fname|HIGH}}) et que la tension est forcée au niveau bas ({{fname|LOW}}) lorsque le bouton est pressé. |
| | | | |
| | [[fichier:RASP-SENSE-HAT-ASTRO-PI-Bouton-03.png]] | | [[fichier:RASP-SENSE-HAT-ASTRO-PI-Bouton-03.png]] |
| | | | |
| − | In the diagram above we wire the GPIO pin to 3.3 volts through a large 10k ohm resistor so that it always reads {{fname|HIGH}}. Then we can short the pin to ground via the button, so that the pin will go {{fname|LOW}} when you press it.
| + | Dans le diagramme ci-dessus la tension de la broche GPIO est placée à 3.3 volts par l'intermédiaire d'une résistance de 10k ohm. La broche est donc toujours au niveau haut ({{fname|HIGH}}). Nous pouvons ensuite "brancher" la broche sur la masse à l'aide du bouton (en pressant dessus) et la tension de la broche passe alors à {{fname|LOW}} (niveau bas). |
| | | | |
| − | So {{fname|HIGH}} means button up and {{fname|LOW}} means button down.
| + | Par conséquent, le niveau haut ({{fname|HIGH}}) signifie que le bouton n'est pas enfoncé et le niveau bas ({{fname|LOW}}) signifie qu'il est enfoncé. |
| | | | |
| − | Fortunately, the Raspberry Pi has all the above circuitry built in; we can select a pull up circuit in our code for each GPIO pin, which sets up some internal circuitry that is too small for us to see. So you can get away with just using two jumper wires here, although you're welcome to wire it up the way shown above if you wish.
| + | Nous avons de chance, le Raspberry Pi dispose de tout ce circuit en interne; nous pouvons activer le circuit "pull up" de la broche dans notre code (indépendamment pour chaque broche GPIO). Ce circuit "pull up" est tellement petit que nous ne pouvons pas le voir. Cool, nous pouvons nous en sortir avec juste avec quelques fils et il nous reste plus qu'à faire nos raccordements en fonction de nos désirs. |
| | | | |
| − | All we now need to do is create the above circuit six times for each of the GPIO pins.
| + | Tout ce qu'il nous reste à faire c'est de créer le circuit ci-dessus 6 fois... un fois pour chaue broche du GPIO. |
| | | | |
| | == Branchement sur breadboard == | | == Branchement sur breadboard == |