Arduino Robot-Guide démarrage

De MCHobby - Wiki
Sauter à la navigation Sauter à la recherche


MCHobby investit du temps et de l'argent dans la réalisation de traduction et/ou documentation. C'est un travail long et fastidieux réalisé dans l'esprit Open-Source... donc gratuit et librement accessible.
SI vous aimez nos traductions et documentations ALORS aidez nous à en produire plus en achetant vos produits chez MCHobby.

Arduino Robot

= Présentation

Avec Arduino Robot, vous pouvez en apprendre plus à propos de l'électronique, mécanique et logiciel. C'est une petit ordinateur sur roues. Il est livré avec une certaine quantité de projet exemples que vous pouvez facilement dupliquer. Arduino Robot est une plateforme robotique puissante sur laquelle vous pouvez faire du hacking pour réaliser toute sorte de tâches.

RB-ARD-ROBOT-50.png
Crédit: Arduino arduino.cc

Le robot est livré avec de nombreuses entrées; deux potentiomètres, cinq boutons, un compas/boussole digital(e), cinq senseur de sol (floor sensor) et un lecteur de carte SD. En sortie,il dispose d'un haut-parleur, de deux moteurs et d'un écran couleur. Vous pouvez contrôler tout ces senseurs et actuateurs à l'aide de la librairie du robot.

Il y a deux cartes différentes sur le Robot: La carte de contrôle (Control Board) au dessus et la carte moteur (Motor Board) en bas.

Si vous débutez en électronique et programmation alors vous devriez commencer par utiliser la carte de contrôle. Lorsque vous serez plus expérimenté, vous pourrez aussi tripatouiller la carte moteur.

Des noms de fonction en anglais: même pas peur

Notre but chez MCHobby est d'offrir des tutoriels accessibles aux plus jeunes... raison pour laquelle nous produisons activement du contenu en Français.

Cependant, disposer d'un vocabulaire minimum en anglais peut-être fort utile. En effet, les librairies et nom de fonctions sont en anglais. Pour activer les moteurs, vous n’appelez pas la fonction écrireMoteur mais motorWrite... d'où l'utilité d'un vocabulaire minimum en anglais.

  • Moteur = Motor
  • Lire = Read
  • Ecrire = Write
  • Ecran = Screen
  • Begin = commencer/démarrer
  • Senseur = Sensor
  • Haut-Parleur = Speaker
  • Entrée = input
  • Sortie = output

Carte de contrôle

{{{2}}}
Crédit: Arduino arduino.cc Traduction MCHobby.be

Carte moteur

{{{2}}}
Crédit: Arduino arduino.cc Traduction MCHobby.be

Préparation du Robot

Lorsque vous ouvrez la boite de votre robot, la première fois vous devez assembler quelques éléments pour que votre robot soit prêt à rouler.

Premièrement, vous devez insérer la carte SD dans l'emplacement prévu à l'arrière de l'écran TFT, puis insérer l'écran sur le connecteur prévu à cet effet au dessus de la carte de contrôle du robot. L'écran doit être orienté avec le texte bleu "SD Card" proche des boutons et du haut-parleur.

RB-ARD-ROBOT-55.png
Crédit: Arduino arduino.cc

Une fois que c'est en place vous devez attacher le cache protecteur sous la carte du bas (carte moteur). Cela prévient les dommages éventuels causés par les objets présent sur le sol. Attachez le cache protecteur sous le robot comme indiqué ci-dessous.

RB-ARD-ROBOT-57.png
Crédit: Arduino arduino.cc

Contenu de la carte SD

La carte SD est utilisé pour stocker des informations que le robot peut lire. Elle est livrée avec des images et fichiers audio qui sont utilisés par les exemples du répertoire Explore (Explore est un terme anglais signifiant "explorer"). Une fois à l'aise avec avec les fonctionnalités du robot, vous devriez être en mesure d'ajouter vos propres fichiers.

Si vous effaciez, par accident, un fichier utilisé par les exemples "Explore", vous pouvez facilement restaurer le contenu de la carte depuis le répertoire "SDcontent" situé dans la librairie du robot.

Brancher le Robot sur le PC

Chaque carte du robot dispose de son propre microcontroleur, qui se programme indépendamment de l'autre. Il est recommandé de ne programmer que la carte de contrôle (celle du dessus) jusqu'à ce que vous soyez familiarisé avec les fonctionnalités du robot. La carte moteur (carte du bas) dispose d'un firmware capable de répondre aux cas d'utilisation les plus courants.

RB-ARD-ROBOT-56.png
Crédit: Arduino arduino.cc

Connectez la carte de contrôle sur votre ordinateur à l'aide du cable USB.

Après avoir connecté la carte, la led verte marquée "PWR" (abrégé de Power signifiant alimentation/puissance) s'allume sur la carte. La LED1 située en dessous clignotera une certain nombre de fois. Sur la carte moteur, c'est la les LEDs rouges libellées LED1 à LED5 (du côté opposé à l'interrupteur d'alimentation) qui doivent également s'allumer.

Si les LEDs sur l'une ou l'autre des cartes ne s'allume pas alors vérifiez le câble de communication à 10 broches situé à côté de l’interrupteur d'alimentation. Ce câble deoit être connecté sur les deux cartes.

Installer les pilotes

Instructions pour Mac OS X

La première fois que vous connectez un Esplora sur un Mac, l'assisant de configuration de clavier ("Keyboard Setup Assistant") est démarré. Il n'y a rien à configurer avec un Esplora, vous pouvez donc fermer cette boite de dialogue en cliquant sur le bouton rouge en haut à gauche de la fenêtre.

Ard-Esplora-Demarrer-Install-10.jpg
Crédit: Arduino arduino.cc

Instructions for Windows

Les instructions suivantes concerne Windows 7. Elles sont également valable pour XP, avec quelques différences relatives au contenu des fenêtres.

  • Branchez votre carte et attendez que Windows commence le processus d'installation des pilotes.

Ard-Esplora-Demarrer-Install-20-pre-a.jpg
Crédit: Arduino arduino.cc
Ard-Esplora-Demarrer-Install-20-pre-b.jpg
Crédit: Arduino arduino.cc

  • Si le programme d'installation ne démarre pas automatiquement, naviguez jusqu'au Gestionnaire de périphérique (Windows Device Manager) via le menu Démarrer > Panneau de configuration > Gestionnaire de périphérique et cherchez après Arduino Esplora dans la liste. Faites un click droit et sélectionnez Mettre le pilote à jour... (Update driver).

Ard-Esplora-Demarrer-Install-20.jpg
Crédit: Arduino arduino.cc

  • A l'écran suivant, sélectionnez "Rechercher un pilote sur mon ordinateur" ("Browse my computer for driver software") et cliquez sur Suivant si nécessaire.

Ard-Esplora-Demarrer-Install-21.jpg
Crédit: Arduino arduino.cc

  • Cliquez sur le bouton Parcourir.... Une autre boite de dialogue apparait: naviguez dans le répertoire contenant les logiciels Arduino (que vous venez juste de télécharger). Sélectionnez le répertoire drivers (terme anglais signifiant "pilote") et cliquez sur OK, puis Suivant.

Ard-Esplora-Demarrer-Install-22.jpg
Crédit: Arduino arduino.cc

  • Vous allez recevoir un notification vous indiquant que la carte n'a pas obtenu la certification Windows. Si c'est le cas, cliquez sur le bouton Continuer quand même.

Ard-Esplora-Demarrer-Install-23a.jpg
Crédit: Arduino arduino.cc
RB-ARD-ROBOT-60.jpg
Crédit: Arduino arduino.cc

  • Après quelques instant, Windows vou informe qu'il à terminé l'installation de la carte Arduino Esplora. Pressez le bouton Fermer.

Instructions pour Linux

Il n'est pas nécessaire d'installer des pilotes pour Ubuntu 12.04.

Bonjour Utilisateur! (Hello User!)

Arduino Robot est livré avec une application préchargée qui vous demande le nom (name en anglais) du robot et où vous bous trouvez. Suivre les instructions sur l'écran du robot pour savoir comment entrer ces informations à l'aide du potentiomètre et des boutons.

Vous pouvez utiliser 4 piles AAA ou connecter le câble USB pour alimenter le robot (moteurs ou carte de contrôle).

RB-ARD-ROBOT-70.jpg
Crédit: Arduino arduino.cc

Une fois que vous avez réaliser toutes les étapes d'installation du robot, vous pouvez commencer à écrire vos propres programmes pour le contrôler.

Le croquis de test

To program the robot, connect the Control Board to your computer via USB. Open the Arduino IDE, and load the sketch located in File > Examples > Robot_Control > learn > MotorTest.

You need to tell the IDE which Arduino board you are targeting with your software, so open the Tools > Board menu and choose Arduino Robot Control.

The Arduino IDE must know which of your USB ports the robot is connected to. The Tools > Serial menu lists the available ports.

  • if only one item is shown, click on that one.
  • if two or more are shown, you can disconnect the Control Board and re-open the menu; the entry that disappears should be the robot. Reconnect the board and select that serial port.

Click the "Upload" button in the top left of the IDE window. Wait a few seconds - you should see the RX and TX leds on the board flashing. If the upload is successful, the message "Done uploading." will appear in the status bar of the software. Once this appears, you can disconnect the robot from the USB cable

With batteries in the robot, turn on the power switch and put it on the ground. The robot should show you a few basic moves. Congratulations! You've gotten the robot up and running.

If the robot is not moving, turn the power switch off. Connect the motor board to the computer with a USB cable. Load the File > Examples > Robot_Motor > Robot_Motor_Core sketch in the IDE, and select Arduino Robot Motor from the Boards menu. Upload this sketch, disconnect from the computer and try turning it on again.

  • Open a very simple sketch, like Blink or BareMinimum
  • Press the upload button
  • When the status bar shows "Uploading...", double press the reset button on the Control Board
  • The Serial port should appear as normally.

Faire déplacer le robot

his sketch moves the robot back and forth repeatedly.

Whenever you're writing code for the robot, make sure to include <ArduinoRobot.h> at the beginning of the sketch. This imports the necessary libraries to control the robot.

There's no need to initialize the Robot object.

To get the wheels to move, call Robot.motorsWrite(). motorsWrite() requires 2 arguments, the speed of the left motor, and the speed of the right motor. These values range from -255 to 255, where -255 is full reverse, and 255 is full speed forward. If you pass a value of 0, the motor will stop spinning the wheel.

Once you've uploaded the sketch, unplug the USB cable for the robot. Whenever the USB is connected, the robot's motors are disengaged. Turn on the power and watch it move around!

#include <ArduinoRobot.h> // import the robot library

void setup(){
  Robot.begin(); // initialize the library
}

void loop(){
  // move forward for one second
  Robot.motorsWrite(255,255);
  delay(1000);

  Robot.motorsWrite(0,0); // stop moving
  delay(1000);

  // move backwards for one second
  Robot.motorsWrite(-255,-255);
  delay(1000);

  Robot.motorsWrite(0,0); // stop moving
  delay(1000);
}

Lire les boutons

You'll be writing a sketch that prints the button presses to the screen.

First, you need to include the Robot library.

 #include <ArduinoRobot.h>

In setup(), start the robot and the screen.

void setup(){
  Robot.begin();
  Robot.beginLCD();
}

In loop(), every 100ms, read the state of the buttons. If one is being pressed, write the name to the screen.

void loop(){
  Robot.debugPrint(Robot.keyboardRead(), 10, 10);
  delay(100);
}

In the explore folder of the robot examples, there is a sketch called Logo, which incorporates this example with the robot movement from above.

Changer la vitesse moteur avec le potentiomètre

This lets you control the speed at which the robot moves in a straight line. By turning the knob and mapping the values to -255 to 255, you will set the speed and direction (forward or backwards) of the robot.

First, you need to include the Robot library.

 #include <ArduinoRobot.h>

In setup(), start the robot and the screen.

void setup(){
  Robot.begin();
  Robot.beginLCD();
}

In loop(), read the value of the potentiometer with Robot.knobRead(). Map its value (a number between 0 and 1023) to -255 to 255. Print this value to the screen, and use it to change the speed of the motors.

void loop(){
  int val=map(Robot.knobRead(),0,1023,-255,255);
  Robot.debugPrint(val);
  Robot.motorsWrite(val,val);
  delay(10);
}

The robot's motor is disengaged when plugged in via USB. After programming the robot, unplug the USB cable and add batteries. Turn on the power switch and watch the robot move. Catch the robot, and change the knob to change its speed.

Faire du bruit

Making some noise

The robot has two different means of producing sounds. There's simple beeping, but the robot can also create more complex sounds by reading sequenced music off the SD card. In this example you'll start with the beeping. To learn about the more complex playback, see the Melody example in the learn folder.

First, you need to include the Robot library.

 #include <ArduinoRobot.h>

In setup(), start the robot and the screen.

void setup(){
  Robot.begin();
  Robot.beginSpeaker();
}

In loop(), you can call Robot.beep() to create a beep. There are three different kinds of beeping; a simple beep, a double beep, and a long beep.

void loop() {
  Robot.beep(BEEP_SIMPLE);
  delay(1000);
  Robot.beep(BEEP_DOUBLE);
  delay(1000);
  Robot.beep(BEEP_LONG);
  delay(1000);
}

Prochaine étape

There are many things you can do with the robot. The few examples on this page don't do it justice. To see some more complex examples that of what the robot can do, look at the sketches found in the Explore folder of the robot examples. These are more complete examples that show you some different applications for the robot.

To learn about more of the functionality of the specific inputs and outputs of the robot, look at the learn folder in the robot examples.

Vous pouvez consulter la librairie du robot et la page de présentation du matériel pour plus d'informations concernant les aspects techniques du Robot.


Source: Arduino Robot, getting started with the Arduino Robot, the Robot's library pages. Crédit: Arduino.cc, licence Creative Common Attribution ShareAlike.

Toute référence, mention ou extrait de cette traduction doit être explicitement accompagné du texte suivant : «  Traduction par MCHobby (www.MCHobby.be) - Vente de kit et composants » avec un lien vers la source (donc cette page) et ce quelque soit le média utilisé.

L'utilisation commercial de la traduction (texte) et/ou réalisation, même partielle, pourrait être soumis à redevance. Dans tous les cas de figures, vous devez également obtenir l'accord du(des) détenteur initial des droits. Celui de MC Hobby s'arrêtant au travail de traduction proprement dit.