To set a pin as output, you also need two lines of code:
+
Pour activer une broche comme une sortie ("''output''" en anglais), vous avez besoin d'utiliser deux lignes de code:
−
<nowiki># Set pin 0 to output (you can set pins 0..15 this way)
+
<nowiki># Activer la broche 0 comme sortie/output
+
# (vous pouvez initialiser les broches de 0 à 15 de cette facon)
mcp.config(0, OUTPUT)
mcp.config(0, OUTPUT)
−
# Set pin 0 High
+
# assigner la sortie 0 - état haut/High
mcp.output(0, 1)
mcp.output(0, 1)
−
# Set pin 0 Low
+
# Assigner la sortie 0 - état bas/Low
mcp.output(0, 0)</nowiki>
mcp.output(0, 0)</nowiki>
−
That's all there is to it! The default sample code will toggle the GPIO pin as fast as possible, and if you hooked it up to an oscilloscope you'd end up with something similar to the following:
+
C'est tout ce qu'il faut faire! Le code d'exemple essaye de basculer la broche GPIO aussi vite que possible... et si vous y branchez un oscilloscope vous devriez voir quelquechose comme ce qui suit: