issue116:python
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
issue116:python [2017/01/02 15:40] – créée auntiee | issue116:python [2017/01/11 17:28] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ==== 1 ==== | ||
+ | ** | ||
Welcome back to our continuing journey to control our world using Python, the Raspberry Pi, and microcontrollers like the Arduino Uno. In this leg of our journey, we will be learning the basics of the Arduino. | Welcome back to our continuing journey to control our world using Python, the Raspberry Pi, and microcontrollers like the Arduino Uno. In this leg of our journey, we will be learning the basics of the Arduino. | ||
This requires us to have a basic understanding of the Arduino and the Arduino programming language, which, unfortunately, | This requires us to have a basic understanding of the Arduino and the Arduino programming language, which, unfortunately, | ||
+ | ** | ||
+ | Je vous re-souhaite la bienvenue dans notre voyage vers le contrôle de notre monde avec Python, le Raspberry Pi, et les microcontrôleurs comme l' | ||
+ | |||
+ | Pour ceci, on a besoin de comprendre les bases de l' | ||
+ | |||
+ | ** | ||
The Arduino Microcontroller | The Arduino Microcontroller | ||
Ligne 16: | Ligne 24: | ||
Bottom right is an image of a “standard” (albeit dusty) Arduino Uno board. | Bottom right is an image of a “standard” (albeit dusty) Arduino Uno board. | ||
+ | ** | ||
+ | Le microcontrôleur Arduino | ||
+ | |||
+ | L' | ||
+ | |||
+ | Essentiellement, | ||
+ | |||
+ | Vous pouvez vous procurer des cartes Arduino authentiques pour environ 35 $, mais il y a aussi de bonnes répliques (surtout la Sparkfun Red Board) pour environ 20 $. | ||
+ | |||
+ | Je vous suggère deux cartes pour nos projets. La UNO et la MEGA. Voir en haut à droite pour un descriptif des deux. | ||
+ | |||
+ | Si vous désirez aller plus loin que nos projets de base, vous pourrez envisager l' | ||
+ | |||
+ | En bas à droite, la photo d'une carte Arduino Uno « standard » (quoique un peu sale). | ||
+ | |||
+ | ==== 2 ==== | ||
+ | ** | ||
Open the Arduino IDE and select File | Examples | 01.Basics | Blink . This will cause another window to open with the new source code. I've copied it here (next page) so we can discuss this very simple project. | Open the Arduino IDE and select File | Examples | 01.Basics | Blink . This will cause another window to open with the new source code. I've copied it here (next page) so we can discuss this very simple project. | ||
Ligne 26: | Ligne 51: | ||
In this setup function, we only have to tell the board that pin number 13 will function as an output pin. On the Uno and Mega, there is an onboard LED that is connected to pin 13, so we will be controlling that, as well as the actual pin, and not have to worry about any external components this time.. In the Loop function, we send, via the digitalWrite function, a High signal turning the LED on, wait 1 second (using the delay function), set it back to a low signal turning off the LED, wait another second, and then start the process all over. | In this setup function, we only have to tell the board that pin number 13 will function as an output pin. On the Uno and Mega, there is an onboard LED that is connected to pin 13, so we will be controlling that, as well as the actual pin, and not have to worry about any external components this time.. In the Loop function, we send, via the digitalWrite function, a High signal turning the LED on, wait 1 second (using the delay function), set it back to a low signal turning off the LED, wait another second, and then start the process all over. | ||
+ | ** | ||
+ | Ouvrez l'EDI de l' | ||
+ | |||
+ | Évidemment, | ||
+ | |||
+ | La partie du haut est un bloc de commentaires qui commence avec un « /* » et se termine avec un « */ ». Comme pour Python, le compilateur C ignore ces blocs de commentaires. Les lignes qui commencent par « // » sont des lignes de commentaires simples et peuvent être mises n' | ||
+ | |||
+ | Il y a deux fonctions qui doivent être incluses dans chaque projet : la fonction de démarrage et la fonction de boucle. Vous pouvez écrire les vôtres, mais il doit y avoir les deux. La fonction de démarrage est lancée à chaque fois que la carte est allumée ou que l'on appuie sur le bouton reset. Une fois qu' | ||
+ | |||
+ | Dans cette fonction de démarrage, nous devons seulement dire à la carte que la broche n° 13 fonctionnera comme une sortie. Sur la Uno et la Mega, il y a une LED qui est connectée à la broche 13, nous pourrons ainsi la contrôler, au même titre que la broche elle-même, et n' | ||
+ | |||
+ | ** | ||
Plug your Arduino board into the USB port of your computer and click on the round check-mark button to compile and verify your code. Once it reports that the compile has completed successfully, | Plug your Arduino board into the USB port of your computer and click on the round check-mark button to compile and verify your code. Once it reports that the compile has completed successfully, | ||
Ligne 32: | Ligne 69: | ||
Now let's start to have a little fun modifying this code. The delay function takes one parameter, which is the number of milliseconds to delay. In this case we are waiting 1000 milliseconds, | Now let's start to have a little fun modifying this code. The delay function takes one parameter, which is the number of milliseconds to delay. In this case we are waiting 1000 milliseconds, | ||
+ | ** | ||
+ | Branchez votre carte Arduino sur le port USB de votre ordinateur et cliquez sur le bouton à cocher rond pour compiler et vérifier votre code. Une fois qu' | ||
+ | |||
+ | Si vous avez des messages d' | ||
+ | |||
+ | Maintenant amusons-nous un peu à modifier ce code. La fonction delay prend un argument, le nombre de millisecondes à attendre. Dans notre cas nous attendons 1000 millisecondes, | ||
+ | |||
+ | ** | ||
delay(250); | delay(250); | ||
Ligne 46: | Ligne 91: | ||
Until then, play with some of the sample projects that you find in the Arduino IDE and have fun. | Until then, play with some of the sample projects that you find in the Arduino IDE and have fun. | ||
+ | ** | ||
+ | |||
+ | delay(250); | ||
+ | |||
+ | N' | ||
+ | |||
+ | Normalement, | ||
+ | |||
+ | Soyons un peu plus créatifs. Faisons en sorte que la carte envoie le code morse S.O.S. C'est à dire trois clignotements courts, un petit delai, trois clignotements longs, un petit délai, et trois courts de plus. Je ne vais pas essayer de faire le malin pour cette étape, mais simplement copier/ | ||
+ | |||
+ | Compilez et chargez le code. | ||
+ | |||
+ | La prochaine fois, nous commencerons à travailler avec des composants que nous avons utilisés précédemment dans nos projets Raspberry Pi ; soyez prêts en ramenant des LED et des résistances de vos placards. | ||
+ | |||
+ | En attendant, jouez avec quelques-uns des exemples de projets que vous trouverez dans l'EDI d' | ||
+ |
issue116/python.1483368010.txt.gz · Dernière modification : 2017/01/02 15:40 de auntiee