Outils pour utilisateurs

Outils du site


issue118:python

Before we get too far along, there is a new version of the Arduino IDE (1.8.0) available at https://www.arduino.cc/en/Main/Software#/?, so it would be a good idea if you download and install it before continuing. If you aren’t using your RPi for your Arduino programming, go ahead and dust it off and install the new Arduino IDE on it so you’ll be ready for next month. This month, we’ll be controlling the Servo motor we used a few months ago on the RPi. The Hardware Our hardware requirements this time are very simple and you should already have everything needed: • 5 VDC Servo Motor • Arduino Uno (or clone) • Breadboard • Jumpers • 10K Potentiometer

Avant d'aller trop loin, il y a une nouvelle version de l'IDE Arduino (la 1.8.0), qui est disponible à https://www.arduino.cc/en/Main/Software#/? ; ce serait une bonne idée de la télécharger et l'installer avant de continuer. Si vous n'utilisez pas votre RPi pour la programmation d'Arduino, allez-y, dépoussiérez-le et installez-y le nouvel IDE Arduino afin d'être prêt pour le mois prochain.

Ce mois-ci, nous contrôlerons le servomoteur que nous avons utilisé sur le RPi il y a quelques mois.

Le matériel

Le matériel dont nous aurons besoin cette fois-ci est très simple et vous devriez déjà tout avoir : • Un servomoteur DC de 5V. • L'Arduino Uno (ou clone). • Une plaque d'essais. • Des cavaliers. • Un potentiomètre de 10 kΩ.

Wiring Once again, for our first two projects, we’ll use the same wiring/breadboard setup – even though the potentiometer is not used in the sweep program. And for those who are interested, here’s the schematic… Sweep This sample code (next page, top right), and the next sample, are from the Arduino IDE Examples, so you really won’t need to copy the code. Just open the IDE, Select File | Examples | Servo. and the Sweep code. The code is already well documented, so we won’t need to discuss much about it. Plug in your Arduino, upload the code to it, and you’ll see that the servo starts sweeping back and forth.

Câblage

À nouveau, pour les deux premiers projets, nous utiliserons la même configuration câblage/plaque d'essais, bien que le potentiomètre ne s'utilise pas dans le programme de balayage.

Pour ceux que cela intéresse, voici le schéma :

Balayage

Je tiens ce code échantillon (en haut à droite de la page suivante) ainsi que le suivant, des Arduino IDE Examples sur le site d'Arduino et vous n'aurez donc pas besoin de le copier. Il suffit d'ouvrir l'IDE, Select File (Sélectionner un fichier) | Examples | Servo. et le code « Sweep » (Balayage). Puisque le code est déjà très bien documenté, nous n'aurons pas besoin d'en parler beaucoup.

Branchez votre Arduino, téléversez le code dessus et vous verrez que le servomoteur commence à balayer de gauche à droite et de droite à gauche.

Knob Just as in the sweep program, the example code is found in the Arduino IDE under File | Examples | Servo | Knob. And again, the code is very well documented already, so no major discussion will be needed. Again, pull up the code in the IDE, upload it to your Arduino, and when you turn the potentiometer, you should see the servo swing in response to the position of the potentiometer. As I said earlier, next month we will be working with the Raspberry Pi to control the Arduino, so break it back out, and get ready.

Bouton

Tout comme pour le programme sweep, le code se trouve dans l'IDE Arduino sous File | Examples | Servo | Knob (bouton). Et, à nouveau, le code est déjà très bien documenté et une discussion importante à son sujet serait superflue.

À nouveau, récupérez le code dans l'IDE, téléversez-le sur votre Arduino et, quand vous tournerez le potentiomètre, vous verrez que le servomoteur commence à balayer en réponse à la position du potentiomètre.

Comme j'ai déjà dit plus tôt, le mois prochain, nous utiliserons le Raspberry Pi pour contrôler l'Arduino, alors recherchez-le et tenez-vous prêt.

issue118/python.txt · Dernière modification : 2017/03/08 08:01 de d52fr