Outils pour utilisateurs

Outils du site


issue48:tuto-arduino

With the Heathkit company gone, and with a modern computer using Ubuntu 10.04 LTS, I found a website detailing a micro-controller named Arduino at www.arduino.cc (not .com). It used a USB cable for power and its computer connection. Arduino Uno was affordable at $30. A simple traffic light simulation on a breadboard seemed just the fun experiment to try. Getting things to work involved just three main tasks: • Installing and configuring the Arduino IDE (Integrated Development Environment), • Figuring out the wiring for the breadboard and the Arduino ports needed, and • Writing a simple C program followed by an upload of the compiled code to the Arduino micro-controller. Task 1 was simple, 2 was routine with some refresher study, and 3 required a small learning curve about C procedures - along with some new commands specific to the Arduino ports. Uploading the compiled code to the micro-controller was easy. Within a few days of fussing with things, my system finally worked as designed. Later, I updated my code to include a buzzer in the circuit.

Avec le départ de la compagnie Heathkit et avec un ordinateur moderne utilisant Ubuntu 10.04 LTS, j'ai trouvé un site détaillant un micro-contrôleur nommé Arduino sur www.arduino.cc (pas .com). Il utilisait un câble USB pour l'alimentation et sa connexion à l'ordinateur. Arduino Uno était abordable à 30 $. Une simulation de feu de circulation simple sur un circuit imprimé semblait être la bonne expérience amusante à essayer.

Faire fonctionner ça consistait seulement en trois tâches principales : • Installer et configurer l'IDE Arduino (Integrated Development Environment ou Environnement de Développement Intégré). • Déterminer le câblage pour le circuit imprimé et les ports Arduino nécessaires. • Écrire un programme C simple suivi de l'envoi du code compilé sur le micro-contrôleur Arduino.

La première tâche était simple, la deuxième a été de la routine avec quelques cours de recyclage, et la troisième nécessitait une petite courbe d'apprentissage sur les procédures C - avec quelques nouvelles commandes spécifiques aux ports Arduino. Télécharger le code compilé sur le micro-contrôleur a été facile. Après quelques jours de tâtonnements, mon système a finalement fonctionné comme prévu. Plus tard, j'ai mis à jour mon code pour inclure une sonnerie dans le circuit.

Part 1: Installing the Arduino IDE (for details see http://arduino.cc/playground/Linux/Ubuntu) I used the “Ubuntu without 'arduino' package” section of the page for my install. (Your installation may vary.) Download the .gtz file, and install it with Archive Manager: aduino-0022.gtz (from http://arduino.cc/en/Main/Software using the Linux 32-bit package) Install the compiler and the libraries packages: sudo apt-get install gcc-avr avr-libc

Partie 1 : Installation de l'IDE Arduino (pour plus de détails voir http://arduino.cc/playground/Linux/Ubuntu).

J'ai utilisé la section « Ubuntu sans le paquet Arduino » de la page pour mon installation (ça peut être différent pour vous).

Téléchargez le fichier .gtz et installez-le avec le gestionnaire d'archives : aduino-0022.gtz (pris sur http://arduino.cc/en/Main/Software en utilisant le paquet Linux 32-bit).

Installez le compilateur et les paquets de bibliothèques :

sudo apt-get install gcc-avr avr-libc

For those using the USB port to dialog, add yourself to the group 'dialout' to have write permissions at that port with: sudo usermod -aG dialout <your username> Next, to run the application, open the “arduino-0022” folder, right click “arduino” and choose “Run”. Once the IDE is running, select your board (mine was the Arduino Uno) from Tools > Board. Part 2: Wiring the breadboard and connecting it to the Arduino Here are the parts I used to complete the wiring (mostly from Radio Shack):

Pour ceux qui utilisent le port USB pour dialoguer, ajoutez-vous au groupe « dialout » pour avoir les permissions d'écriture sur ce port avec :

sudo usermod-aG dialout <votre nom d'utilisateur>

Ensuite, pour exécuter l'application, ouvrez le dossier « arduino-0022 », faites un clic droit sur « arduino » et choisissez « Exécuter ». Une fois que l'IDE est en cours d'exécution, sélectionnez votre carte (la mienne était l'Arduino Uno) à partir de Outils > Carte.

Partie 2 : Câblage du circuit imprimé et connexion à l'Arduino.

Voici les pièces j'ai utilisées pour effectuer le câblage (achetées surtout chez Radio Shack) :

• breadboard and a few spools of 22-gauge, insulated, solid-core wire • 2.1mm power plug, and 9-volt battery cap (solder red lead to the center tap, black lead to the outside tap) • 9-volt battery • LEDs: 2 red, 2 green, 1 yellow (approx 2.1 mA forward current each. Note the orientation!) • breadboard push button switch • 3VDC Mini Buzzer (Radio Shack 273-0053) • resistors 5-220 Ohm, 2-150 Ohm, 1-10K Ohm (all 1/8 Watt okay) Shown below is the wiring schematic, and a view of my Arduino mounted on a wood frame with the breadboard and the wires. (The Lego board was used to hold things loosely together.)

• un circuit imprimé et du câble électrique isolé de calibre 22 à âme pleine ; • une prise de courant de 2,1 mm et capuchon de pile de 9 volts (fil rouge soudé à la prise centrale, fil noir soudé à la prise extérieure) ; • une pile de 9 volts ; • des LED : 2 rouges, 2 vertes, 1 jaune (environ 2,1 mA chaque. Notez l'orientation !) ; • un interrupteur à bouton poussoir pour circuit imprimé ; • 3 VDC Mini Buzzer (Radio Shack 273-0053) ; • des résistances : 5 de 220 Ohms, 2 de 150 Ohms, 1 de 10 KOhms (toutes prévues pour 1/8 Watt).

Ci-dessous le schéma de câblage et une vue de mon Arduino monté sur une armature en bois avec la carte et les fils. (Les briques Lego ont été utilisées pour maintenir les choses ensemble.)

Part 3: Writing the code using C, and uploading the compiled code to the Arduino Uno After some reading at the Arduino website, and with some borrowed code, the project code was one page in length using gedit. The file was then renamed 'trafficlightsound.pde' inside a folder named 'trafficlightsound' – the name extension and corresponding folder name that the Arduino IDE seemed to require. Clicking in the IDE's start arrow at the left made the application verify and compile the code of 1468 bytes. The source code for the Arduino traffic lights can be found at: http://pastebin.com/ACk9u937 After connecting a USB cable between the computer and the micro-controller, one click on the right arrow on the second row square of the IDE started the upload of bytecode to the microcontroller. Once loaded, the Arduino Uno ran the various lights and buzzer as designed. After disconnecting the USB cable and connecting the 9-volt battery, the project ran independently from the computer. The program will continue to run in a loop until the power is removed.

Partie 3 : Ecriture du code en C et téléchargement du code compilé sur le Arduino Uno.

Après quelques lectures sur le site Arduino, et avec un peu de code emprunté, le code du projet tenait sur une page dans gedit. Le fichier a ensuite été rebaptisé « trafficlightsound.pde » dans un dossier nommé « trafficlightsound » - l'IDE Arduino semblait exiger cette extension et le même nom pour le dossier et le fichier. En cliquant sur la flèche de démarrage sur la gauche de l'IDE, cela a vérifié et compilé le code de 1468 octets.

Le code source pour les feux de circulation Arduino peut être trouvé ici : http://pastebin.com/ACk9u937.

Après avoir connecté un câble USB entre l'ordinateur et le micro-contrôleur, un clic sur la flèche vers la droite sur la deuxième ligne de l'IDE a lancé le chargement du bytecode vers le microcontrôleur. Une fois chargé, le Arduino Uno a fait fonctionner les différents feux et l'avertisseur sonore comme prévu.

Après avoir débranché le câble USB et branché la batterie de 9 volts, le projet a fonctionné indépendamment de l'ordinateur. Le programme continuera à fonctionner dans une boucle jusqu'à ce que l'alimentation soit coupée.

issue48/tuto-arduino.txt · Dernière modification : 2011/05/20 19:07 de auntiee