Modifications

Sauter à la navigation Sauter à la recherche
5 705 octets ajoutés ,  14 septembre 2013 à 10:34
Ligne 102 : Ligne 102 :  
* if only one item is shown, click on that one.
 
* 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.  
 
* 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.
 +
 +
{{ambox|text=Note: If no Serial port shows up after you plug in the robot, and restarting the IDE/unplug-replug the robot does not help, follow the steps below...}}
 +
 +
* 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!
 +
 +
<nowiki>#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);
 +
}</nowiki>
 +
 +
== 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.
 +
 +
  <nowiki>#include <ArduinoRobot.h></nowiki>
 +
 +
In setup(), start the robot and the screen.
 +
 +
<nowiki>void setup(){
 +
  Robot.begin();
 +
  Robot.beginLCD();
 +
}</nowiki>
 +
 +
In loop(), every 100ms, read the state of the buttons. If one is being pressed, write the name to the screen.
 +
 +
<nowiki>void loop(){
 +
  Robot.debugPrint(Robot.keyboardRead(), 10, 10);
 +
  delay(100);
 +
}</nowiki>
 +
 +
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.
 +
 +
  <nowiki>#include <ArduinoRobot.h></nowiki>
 +
 +
In setup(), start the robot and the screen.
 +
 +
<nowiki>void setup(){
 +
  Robot.begin();
 +
  Robot.beginLCD();
 +
}</nowiki>
 +
 +
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.
 +
 +
<nowiki>void loop(){
 +
  int val=map(Robot.knobRead(),0,1023,-255,255);
 +
  Robot.debugPrint(val);
 +
  Robot.motorsWrite(val,val);
 +
  delay(10);
 +
}</nowiki>
 +
 +
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.
 +
 +
  <nowiki>#include <ArduinoRobot.h></nowiki>
 +
 +
In setup(), start the robot and the screen.
 +
 +
<nowiki>void setup(){
 +
  Robot.begin();
 +
  Robot.beginSpeaker();
 +
}</nowiki>
 +
 +
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.
 +
<nowiki>void loop() {
 +
  Robot.beep(BEEP_SIMPLE);
 +
  delay(1000);
 +
  Robot.beep(BEEP_DOUBLE);
 +
  delay(1000);
 +
  Robot.beep(BEEP_LONG);
 +
  delay(1000);
 +
}</nowiki>
 +
 +
== 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.
 +
 +
Be sure to check out the Robot's library page and the hardware page for more information about the technical aspects of the Robot.
 +
    
{{Arduino-Robot-TRAILER}}
 
{{Arduino-Robot-TRAILER}}
29 836

modifications

Menu de navigation