Introduction

Specifications

Part List

Overview

Overall View

Important Update! Scratch Graphical Programming

Important Update: MAX supports scratch graphical programming on the basis of mind platform of scratch 3.0.

Click to download the latest version.

Guidelines

Step 1: Assemble MAX

The Assemble Manual for Your Reference

Click to download the MAX Assemble Manual (PDF)

Video Tutorial

Click to watch the Assemble Video Tutorial

The assembled MAX:

Explorer.jpg

Step 2: Master 4 Factory Built-in Programs of MAX

Obstacle Avoidance

Ultrasound  Use Process of Obstacle Avoidance

Use Method:

① Confirm that all the wires are properly connected.

② Then install 4 AA batteries.

③ Turn on the power switch, and the main board RGB lamp will emit red rotating light.

④ Put MAX on the ground, MAX will turn to the other side if there is an obstacle about 30cm ahead.

Click to watch the video display

Line-tracking

MAX.jpg

use.jpg

Use method:

① Take out the line-tracking map and lay it on the floor.

② Turn on the power switch and press the function button once, then the top light of the main board will emit a green rotating light.

③ Put MAX on the black line, and he will run along the line.

Click to watch the video display

Light-following

Photosensitive_chase.jpg Chase_process.jpg

Use method:

① Turn on the power switch and press the function button twice, the RGB light will emit a blue rotating light, which means it is switched to the light-following mode.

② Turn on the flashlight function of the mobile phone and illuminate the light sensor next to the ultrasonic wave. Then MAX will follow the strong light.

Click to watch the video display

Bluetooth Remote Control:

Download Goble Use Process of Bluetooth Remote Control Goble

Scan QR code and download GOBLE

Use method:

① Search "GOBLE" in the Apple APP Store or scan the QR code to download the "GOBLE" Bluetooth remote control program.

② Turn on the power and press the function button three times, then the mainboard 4 RGB lights will display 4 colors which means it is switched to Bluetooth mode.

③ Hold the device close to MAX, Bluetooth will be automatically connected. After that, the MAX LINK light will be on, and the Bluetooth logo in the software will turn green.

④ Operate the direction button on the right side, MAX will drive in all directions.

Click to watch the video display

Step 3: Prepare for Learning Programming

Preparation

Turn on the power of MAX, switching the function button, we can realize different functions, such as line-tracking, obstacle avoidance, light following, Bluetooth control and so on. But how are these magical functions implemented? Now, the programs to control the robot will be given one by one. Before the study, we need to do some preparatory work.

Please Prepare the Following Tools
  1. One assembled Explorer Max, as shown below:

Explorer.jpg

  1. One computer and one A-B USB data cable, as shown below:

ROBO137-PC.png

Download and Install Arduino IDE Software
  1. Download Arduino IDE

Open a web page and input website Arduino IDE.

After entering the page, you will find the section shown below.

1.6.12

Windows users: click and download Windows(ZIP file)

Mac, Linux users: choose the correspondent system

Unzip the file after the file is downloaded:

Put the entire Arduino 1.6.12 folder in a familiar location on your computer so you can find it easily.

Open the Arduino 1.6.12 folder, What you will see is as follows.

The unzipped file

  1. Install the driver

Plug one end of the USB into the MAX main board and the other end to the computer. After the two sides have been successfully connected, the red power indicator of the MAX board will light up.

Then, open the control panel and select device manager as shown below:

Device managment

Find other devices > Arduino-xx, right-click and select Update Driver Software. As shown below:

Update driver software

In the pop-up dialog box, select next page --> manually seek and install the driver software. As shown below:

Manually seek and install

Find the Arduino IDE installation location where the above unpacked file is placed. Select the search path to the drivers (as shown below), and click Next

Search path to the driver

Select to always install this driver software (Figure 1), and then the Figure 2 will appear, which shows the successful driver installation.

Driver_6.png MAX1.10.png

At this time, a serial port number will be displayed on the device manager port. (As shown below)

Driver_8.png

  1. Change the language of the interface

Open the Arudino IDE, and then the editing interface of the Arduino IDE will appear. (As shown below)

1.6.12-1.png

An English interface will appear at first. If you are not familiar with it, you can select preferences in the menu bar -->File. (As shown below).

Arduino12.png

Then select Simplified Chinese as the Editor language (as shown below) and click OK. Re-opening the Arduino IDE, it will be the Chinese interface.

MAX1.14.png

Download and Install the MAX Runtime Library
  1. Click to download MAX library file. How to install the library?

  2. Extract the downloaded runtime library and copy it to the libraries folder of the ArduinoIDE installation package.

Get to Know Arduino IDE

Arduino IDE is the software editing environment for Arduino products. Simply put, it is used to write and download code. For all Arduino products, users need to download the code first before running.

The hardware circuits we built must work with auxiliary code, and both of them are indispensable. Just as a person controls the physical activity through the brain. If the code is the brain, the peripheral hardware will be the limb, and the activity of the limb depends on the brain.

So the hardware implementation relies on the code.

Arduino Editing Interface

The requirements of Arduino IDE have been shown in the upper picture. Most white areas in the above image are the editing areas to input the code. Please note that when input the code, you have to switch to the English input method.

The black area below is the message prompt area, which shows whether the compilation or download is ok.

Run the MAX

In the previous chapter, we have got the assembled MAX, the Windows computer, the USB cable, downloaded and installed the ArduinoIDE. We also got familiar with the interface and operation of the ArduinoIDE. Next we will upload a simple program to further learn the ArduinoIDE compilation and download program to MAX. Run the MAX

MAX-P.png

Open the Setup Development Board and Serial Port

1.Click onArduino.png icon to open the default interface as shown below:

The Default Interface

2.Before downloading the program, we must first tell the Arduino IDE board model and the corresponding serial port.

Arduino includes a variety of versions of the main controller, the most common ones are the controllers of the Uno, Leonardo and Mega series. In the board, you need to select the board according to the firmware type of the master hardware you choose. (Using Uno as the controller for MAX in the example) Tools > Development Board > Arduino Uno

Set the Development Board Model

Tools > Ports > xx, the xx here should be selected to be the same as seen in your PC Device Manager

Set the Serial Port

Compile and Download the Program

1.Enter the following codes into ArudinoIDE (You must use English input method to programme, and the code is case-sensitive)

#include <DFRobot_MAX.h>
DFRobot_MAX myMax;
void setup() {
myMax.begin();
}
void loop() {
myMax.forward (150,150);
}

2.Click Arduino-by.png the "Verify" button, and the compiler will prompt that the compilation is finished (see Figure 1 below). (If there is an error, the program will fail to be compiled and report the error (see Figure 2 below).)

MAX2.2.png MAX2.3.png 3.Connect MAX to a computer with a USB cable, as shown below.

MAX-PC.jpg

4.Press Arduino-sc.png "upload" button to upload the program to the MAX.

Upload Successfully

Start MAX

1. Make sure that the left and right electric motors are connected to the motor ports of the main board (see Figure 3 and Figure 4 below).

Figure 3. Two electric motors Figure 4. The motor port of the main board

2.Install 4 AA batteries (or lithium batteries) for MAX and turn on the power switch (see Figure 5 and Figure 6 below).

MAX2.10.png MAX2.11.png

Turn on the switch and we can see MAX running forward!

Start to Learn Programme

MAX's Walking Route

6.1.jpg

Previously on:

In the previous guideline, we have a simple understanding about the download and installation of Arduino and the compilation and download of the program.

The main tasks of this chapter:

Write a program to make MAX drive in a square.

The content of this chapter:

  1. The several main parts of the program
  2. Definition of function
  3. Setup() function and loop() function;
  4. The use of annotations;
  5. The use of the delay function;

Click to download the details of this tutorial:MAX's walking route

MAX's RGB Lights

6.2.jpg

Previously on:

In the last chapter, we learned about the use of annotations, the definition of functions, the setup() and loop() functions, and the use of delay functions.

The main tasks of this chapter:

Let MAX illuminate 4 RGB lights in a circular manner during driving.

The content of this chapter:

  1. The definition of variable
  2. The use of for loop statements
  3. The use of RGB light control functions

Click to download the details of this tutorial: MAX's RGB lights

Use the Button to Turn on the RGB Light

6.3.jpg

Previously on:

In the last chapter, we learned what variables are, and how to use for loop statements and RGB light control functions.

The main tasks of this chapter:

Light up one RGB light on the MAX's back by pressing the button once.

The content of this chapter:

  1. The principle of the button
  2. How to use if statement
  3. The difference between "==" and "="

Click to download the details of this tutorial: use the button to turn on the RGB light

Ultrasonic Ranging

6.4.png

Previously on:

In the last chapter, we studied the button of MAX and the use of if statements.

The main tasks of this chapter:

Use ultrasonic ranging to print the distance value from the serial port.

The content of this chapter:

  1. Introduction to the principle of ultrasonic ranging
  2. The use of ultrasonic ranging function
  3. Learn to use the function serial port prints
  4. The difference between Serial.print() and Serial.println()

Click to download the details of this tutorial: Ultrasonic ranging

Play Sound Effects

6.5.png

Previously on:

In the previous section, we learned how to use ultrasonic ranging to print the distance value from the serial port.

The main tasks of this chapter:

Let MAX play the 1st to 8th sound effects in a circular manner during driving.

The content of this chapter:

  1. Introduction to built-in sound effects
  2. The use of playing sound effects function
  3. The use of while and do...while... statements

Click to download the details of this tutorial: Sound effects

Seven-note Music Car

Seven-note Music Car

Previously on:

In the last chapter, we learned about the use of sound effects function, 16 built-in sound effects, and while, do...while... loop statements.

The main tasks of this chapter:

Play a sound effect every 10cm between 110~40cm, and play the sound effects 1~7 in turn.

The content of this chapter:

  1. To learn if...else if...else judgment statement
  2. To learn logical operators

Click to download the details of this tutorial:Seven-note music car

Obstacle Avoidance Robot

Obstacle Avoidance Robot

MAX's colorful RGB lights

Previously on:

In the last chapter, we learned about the use of logical operators and if...else if...else statements. Besides, by utilizing the principle of ultrasonic ranging, the function of the seven-note music car has been realized as well.

The main tasks of this chapter:

Realize obstacle avoidance functions such as rightward, leftward, spining around and so on when MAX encounters an obstacle. At the same time the RGB light will respectively emit light in blue, fuchsia, and other colors.

The content of this chapter:

  1. The use of the random function random()
  2. The use of the myMax.swerve function
  3. To learn switch...case statement
  4. The difference between if, if...else if, switch...case statements

Click to download the details of this tutorial:Obstacle avoidance robot

Walking Emoticon

 Walking Emoticon

Previously on:

In the last chapter, we learned about the use of the switch...case statement, the random function random(), and the myMax.swreve function.

The main tasks of this chapter:

Let MAX randomly display different expressions during driving.

The content of this chapter:

  1. Introduction to RGB emoticons
  2. The use of the myMax.showFace function
  3. The Use of the myMax.backward function

Click to download the details of this tutorial:Walking emoticon

Custom Emoticon Panel

Custom Emoticon Board

Previously on:

In the last chapter, we learned 23 RGB emoticons and how to use myMax.showFace and myMax.backward functions.

The main tasks of this chapter:

Define the pattern and color of the emoticon.

The content of this chapter:

  1. Learn how to customize your emoticon panel
  2. Learn how to use arrays
  3. The use of Mymax.cusomface functions

Click to download the details of this tutorial:Custom emoticon board

MAX's Small Eyes - Light Sensor

MAX's Small Eyes - Light Sensor

Previously on:

In the last chapter, we learned how to customize the emoticons with arrays.

The main tasks of this chapter:

Use a light sensor to control the two RGB lights on the back of Max, while check the brightness values of both sides on the serial monitor.

The content of this chapter:

  1. Learn the principle of light sensors
  2. Learn how to use a light sensor to control the RGB light

Click to download the details of this tutorial:MAX's small eyes-photosensitive sensor

Light-following Robot

 Light-following Robot

Previously on:

In the last chapter, we learned the principle of light sensor and how to use it to control the RGB lights.

The main tasks of this chapter:

Make a light-following robot, and let MAX drive along the side with strong light.

The content of this chapter:

How to set the parameters of a light sensor.

Click to download the details of this tutorial:Light-following robot

Line-tracking Robot

Line-tracking Robot

Previously on:

In the last chapter, we learned how to set Max to run along the side of strong light.

The main tasks of this chapter:

Make a line-tracking robot, and let Max drive along the black line by using a line-tracking sensor.

The content of this chapter:

  1. Learn to use the line-tracking sensor and its principle
  2. The use of line-tracking lights function
  3. The use of line-tracking sensor function

Click to download the details of this tutorial:Line-tracking robot

Bluetooth Control Robot

Bluetooth Control Robot

Previously on:

In the last chapter, we learned the use of line-tracking sensor and line-tracking light function.

The main tasks of this chapter:

Make a Bluetooth control robot, and control MAX to move in different patterns via the GOBLE software (IOS version).

The content of this chapter:

  1. Learn the use of Goble software
  2. Learn how to set Goble in your code
  3. Learn Goble.available() serial function

Click to download the details of this tutorial:Bluetooth control Robot
Click to download Goble library file:Goble library file
Click to download Infrared library files:Infrared library files

Sound Control Robot

Sound Control Robot

Previously on:

In the last chapter, we learned how to use Goble software to control the way Max walks.

The main tasks of this chapter:

Learn the principles and functions of sound sensors and use sound to control Max's movement.

The content of this chapter:

  1. Learn the principle of sound sensors
  2. Learn what a subfunction is
  3. Learn how to customize subfunctions
  4. Learn the function of the sound sensor

Click to download the details of this tutorial:Sound control robot

Button Expansion - Function Switching

thumb Button Expansion - Function Switching

Previously on:

In the last chapter, we learned the principle of sound sensors and the use of sound sensor functions.

The main tasks of this chapter:

Learn time function, and use button to switch different functions such as light-following, Bluetooth control, line-tracking.

The content of this chapter:

  1. Learn what a time function is
  2. Learn how to switch functions with buttons

Click to download the details of this tutorial:Button expansion-function switching

MAX’s Funny Application Programming

Ultrasonic Music Robot

Click and download Max library file. How to install a library?

 /*
 * @The function of the program: ultrasonic music car
 * @The experimental phenomena: during the driving, MAX will make different tones based on the distance of the obstacles ahead, which is just like playing music.
 * @author [liulihua](lihua.liu@dfrobot.com)
 * @version  V1.0
 * @date  2017-11-22
 */ #include <DFRobot_MAX.h> DFRobot_MAX myMax;
 int u;                     //For storing ultrasonic distance values
 int a[7]={1,1,1,1,1,1,1};  //For making a play sign when playing music
 void setup() {
  myMax.begin();             //Initialize the MAX system
  myMax.forward(70,70);      //Let Max go forward when the program begins.
 }
 void loop() {
   u=myMax.distanceValue(); //Read the ultrasonic distance value
   if(u < 120 && u > 100 && a[0] == 1 ){        //If the distance is between 1.2 meters and 1 meter, the sound effect of No. 1 is played, the flag is set to 0, and the rest is set to 1.
      myMax.playSound(1);
      a[0]=0; a[1]=1; a[2]=1; a[3]=1; a[4]=1; a[5]=1; a[6]=1;
    }
 if(u < 100 && u > 90  && a[1] == 1 ){      //If the distance is between 1 meter to 0.9 meter, the sound effect of NO.2 is played, the flag is set to 0, and the rest is set to 1.
       myMax.playSound(2);
      a[0]=1; a[1]=0; a[2]=1; a[3]=1; a[4]=1; a[5]=1; a[6]=1;
    }
 if(u < 90 && u > 80 && a[2] == 1 ){        //If the distance is between 0.9 meter to 0.8 meter, the sound effect of NO.3 is played, and the rest is set to 1.
      myMax.playSound(3);
      a[0]=1; a[1]=1; a[2]=0; a[3]=1; a[4]=1; a[5]=1; a[6]=1;
    }
    if(u < 80 && u > 70 && a[3] == 1 ){        //ditto
      myMax.playSound(4);
      a[0]=1; a[1]=1; a[2]=1; a[3]=0; a[4]=1; a[5]=1; a[6]=1;
    }
    if(u < 70 && u > 60 && a[4]== 1 ){
      myMax.playSound(5);
      a[0]=1; a[1]=1; a[2]=1; a[3]=1; a[4]=0; a[5]=1; a[6]=1;
    }
    if(u < 60 && u > 50 && a[5]== 1 ){
      myMax.playSound(6);
      a[0]=1; a[1]=1; a[2]=1; a[3]=1; a[4]=1; a[5]=0; a[6]=1;
    }
    if(u < 50 && a[6]== 1 ){
      myMax.playSound(7);
      a[0]=1; a[1]=1; a[2]=1; a[3]=1; a[4]=1; a[5]=1; a[6]=0;
    }
 }

Click to watch: Video demo

Sound and Light Password Lock Robot

Click and download Max library file. How to install a library?

 /*
 * @The function of the program: sound and light password lock car(for example, clap twice, then illuminate the left and light sensors to unlock the car)
 * @The experimental phenomena: operate the car assembled with one sound sensor and two light sensors.
 * @The car starts only when the correct password is entered. A multiple password combination is acceptable here.
 * @author [liulihua](lihua.liu@dfrobot.com)
 * @version  V1.0
 * @date  2017-11-22
 */
 #include <DFRobot_MAX.h>
 DFRobot_MAX myMax;
 void MicVal(int num)                //The function of sound sensor
 {
 int micVal;
  int a=0;
  do{
    delay(1);                      //Eliminate errors
    micVal=myMax.micValue();
    a= a   micVal;
  }while(a < (num * 600) || a == -1 );
  Serial.println("a=");
  Serial.println(a);
  myMax.rgbLed(0, 255, 0, 0);
  return;
 }
 void LightL()                  //The function of left light sensor
 {
 //int lightR;
  int lightL;
  do{
    lightL=myMax.lightValue(1);
    //lightR=myMax.lightValue(0);
  }while(lightL>70 || lightL < 2);
  Serial.println("lightL=");
  Serial.println(lightL);
  myMax.rgbLed(2, 0, 255, 0);
  return;
 }
 void LightR()                     //The function of right light sensor
 {
  int lightR;
  do{
    //lightL=myMax.lightValue(1);
    lightR=myMax.lightValue(0);
  }while(lightR>70 || lightR < 2);
  Serial.println("lightR=");
  Serial.println(lightR);
  myMax.rgbLed(1, 0, 0, 255);
  return;
 }
 void Motor()                      //The function of motor drive
 {
  myMax.forward(120,120);
  myMax.playSound(12);
  myMax.rgbLed(3, 0, 255, 255);
 }
 void setup() {
  myMax.begin();
  Serial.begin(9600);  //It is only for debugging data.
 }
 void loop() {  //Change the order and number of three sensors to change the password.
  MicVal(1);    //The function of calling the sound sensor, and exit the function when there is a clapping sound.
  LightR();    //The function of calling the right light sensor, and exit the function when there is light.
  LightL();    //The function of calling the left light sensor, and exit the function when there is light.
  MicVal(2);   //The function of calling sound sensor, and exit the function when there are two clapping sounds.
  Motor();     //The function of calling motor drive, and make the car move forward, light up the lights and emit sound effects.
 }

Click to watch:Video demo

Obstacle Avoidance Car

Click and download Max library file. How to install a library?

 /*
 * @The function of the program: obstacle avoidance car
 * @The experimental phenomena: during the line-tracking, MAX can judge in time whether there are any obstacle ahead. If there is one in the 50 cm, he will make the sound effect, and spin or turn around to continue the line-tracking, or change the routine.
 * @author [liulihua](lihua.liu@dfrobot.com)
 * @version  V1.0
 * @date  2017-11-22
 */#include <DFRobot_MAX.h>    //Load MAX library
 DFRobot_MAX myMax;
 int l,r,c,u;                 //Define variables: l for the left line-tracking sensor, r for the right line-tracking sensor, c for the middle line-tracking sensor, u for the ultrasonic distance.
 int i=1;                     //A flag for showing whether to play sound effects or not
 void setup() {
  myMax.begin();             //Initialize MAX system
 // Serial.begin(9600);
  myMax.forward(70,70);      //Make MAX move forward when the program begins
  }
 void loop() {
  l=myMax.lineValue(2);    //Read the value of the left line-tracking sensor
  c=myMax.lineValue(1);    //Read the value of the middle line-tracking sensor.
  r=myMax.lineValue(0);    //Read the value of the right line-tracking sensor.
  u=myMax.distanceValue(); //Read the value of the ultrasonic distance.
  //Serial.println(u);
  if(u > 50){                   //Judge whether the distance between the obstacle and the car is less than 50cm, less than, to operate the line-tracking function.
 i = 1;                      //Set the flag to 1. It is used to restart the sound effects playback under obstacle avoidance mode.
    if(l==1 && c==1 && r==1){   //Move slowly if the three line-tracking sensors are on the black line.
      myMax.forward(70,70);
    }else{
        if( l==0 && c==1 && r==0){   //Or else, determine whether the middle line-tracking sensor is on the black line and the left and right sensors on the white line.
          myMax.forward(70,70);      //Move forward if it is.
        }else{
          if((l==0 && c==1 && r==1)||(l==0 && c==0 && r==1)){  //Otherwise, judge whether the right two sensors are on the black line or one of them is on the black line so as to judge if the car is leaning to the left side.
            myMax.forward(150,70);      //Make the car turn right if it is.
            if(l==0 && c==0 && r==0){  //If the car drives too fast and rushes out, which is not detected before
              myMax.forward(130,70);   //still make the car turn right in order to avoid wrong judgement.
              }
          }else{
            if((l==1 && c==0 && r==0)||(l==1 && c==1 && r==0)){  //Or else, determine whether the car is leaning on the right side through the line-tracking sensor.
               myMax.forward(70,150);                            //Make the car turn left if it is.
               if(l==0 && c==0 && r==0){                         //If the car drives too fast and rushes out, which is not detected before
                 myMax.forward(70,150);                          //still make the car turn left in order to avoid wrong judgement.
                 }
               }
             }
          }
       }
    }
  else{                                //If the distance is less than 50cm, perform the obstacle avoidance mode.
    if(i==1){                          //Judge whether the flag is 1 at first.
        i=0;                           //Zero the flag to avoid multiple calls to the sound effects
        myMax.playSound(12);           //play a sound effect
        }
     myMax.forward(0,130);            //If there is an obstacle, let the car turn left.
    }
 }

Click to watch: Video demo

Bluetooth Control Robot

Click and download Max library file. How to install a library?

Click to download Bluetooth goble library file .How to install a library?

 /*
  * @The function of the program: use the Bluetooth remote control program of GOBLE based on IOS version(Chinese name:zouni) to control MAX's movement.
 * @The experimental phenomena: open zouni software and turn on Bluetooth of Apple device. The Bluetooth will be automatically connected if it is near to MAX. After the successful connection, MAX's LINK light will be on. And then, just press the up key of the right side.
 * You can start to control MAX when he moves forward.
 * @author [liulihua](lihua.liu@dfrobot.com)
 * @version  V1.0
 * @date  2017-11-22
 */
 #include <DFRobot_MAX.h>
 #include <GoBLE.h>
 DFRobot_MAX myMax;
 int up,down,left,right; //Define four keys.
 void setup() {
  myMax.begin();
  Serial.begin(115200);
  }
 void loop()
 {
      if (Goble.available())   //If the received Bluetooth data is judged to be valid data, they will be assigned to each key variable.
       up     = Goble.readSwitchUp();
       down   = Goble.readSwitchDown();
       left   = Goble.readSwitchLeft();
       right  = Goble.readSwitchRight();
       if (up == LOW)      //MAX will move forward if the up key is pressed.
         myMax.forward(100,100);
         else if(down == LOW)            //Or else, determine whether the down key is pressed, if it is, move backward.
           myMax.backward(100, 100);
           else if(left == LOW)       //Or else, determine whether the left key is pressed, if it is, turn left.
              myMax.forward(100,200);
             else if(right == LOW)    //Otherwise, determine whether the right key is pressed, if it is, turn right.
               myMax.forward(200,100);

}

Click to watch: Video demo

A Robot that Rushes Around in a Circle

Click and download Max library file. How to install a library?

    /*
     *The function of the program: a robot that travels in certain areas.
     *The experimental phenomena: stick a large circle on a white paper with a black tape. MAX only travels in white paper or black lines. When he encounters black lines, he will make a turn or change direction.
     * @author [liulihua](lihua.liu@dfrobot.com)
     * @version  V1.0
     * @date  2017-11-10
     */
     #include <DFRobot_MAX.h>
     DFRobot_MAX myMax;
     int L;  //Define the left line-tracking sensor.
     int R;  //Define the right line-tracking sensor.
     int M; //Define the middle line-tracking sensor.
     int D; //Define variables for storing random numbers.
     void setup() {
      myMax.begin();             //Initialize MAX system.
      myMax.forward(70,70); //Make MAX move forward when the program begins.
      }
     void loop() {
        L=myMax.lineValue(0);   //Read the value of the left line-tracking sensor.
        R=myMax.lineValue(1);  //Read the value of the right line-tracking sensor.
        M=myMax.lineValue(2);  //Read the value of the middle line-tracking sensor.
        if(L > 0||R > 0||M > 0){     //If one of the three sensors detects a black line, perform the following action.
           myMax.playSound(8);    //Play sound effects
           myMax.backward(70,70);    //MAX moves backward for one second.       delay(1000);
           D=random (0,10); //Generate a random number from 0 to 10
           if(D<5){     //If the generated random number is less than 5, perform the following actions.
           myMax.backward(0,70); //Make MAX turn left and move backward for 1 second.
           delay(1000);
           }
           else
           {
            myMax.backward(70,0); //If the random number is more than 5, make MAX turn left and move backward for one second.
           delay(1000);
           }
        }
       myMax.forward(70,70); //Max continue to move forward.
    }

Click to watch: Video demo

Music Car in Another Dimension

Click and download Max library file. How to install a library?

 /*
 *The function of the program: music car
 *The experimental phenomena: different music scores are played according to the different distances detected by the ultrasound.
 * @author [liulihua](lihua.liu@dfrobot.com)
 * @version  V1.0
 * @date  2017-11-21
 */
 #include <DFRobot_MAX.h>
 DFRobot_MAX myMax;
 int u;
 void setup() {
  myMax.begin();             //Initialize MAX system.
  delay(150);
  //Serial.begin(9600);
  myMax.forward(70,70);      //Make MAX move forward when the program begins.
   }
 void loop() {
    u=myMax.distanceValue(); //Read the value of the ultrasonic distance
    //Serial.println(u);
   switch(u){
      case 30:myMax.playSound(7);delay(20);break; //If the distance is detected to be 30cm, the corresponding music is played. This statement is to play the 7th score.
      case 50:myMax.playSound(6);delay(20);break;
      case 70:myMax.playSound(5);delay(20);break;
      case 90:myMax.playSound(4);delay(20);break;
      case 110:myMax.playSound(3);delay(20);break;
      case 130:myMax.playSound(2);delay(20);break;
      case 150:myMax.playSound(1);delay(20);break;  //Play 7 music scores.
    }
}

Sound Control Car MAX

Click and download Max library file. How to install a library?

 /*
 * @The function of the program: sound control car.
 * @The experimental phenomena: use clapping to control the car to move forward and backward. Clap once, go forward, clap again and go backward, rolling on in cycles.
 * @author [liulihua](lihua.liu@dfrobot.com)
 * @version  V1.0
 * @date  2017-11-30
 */
 #include <DFRobot_MAX.h>
 DFRobot_MAX myMax;
 int i=1;                    //Define a flag to determin to make the car move forward or backward.
 void MicVal()                //The function of sound sensor.
 {
  int micVal;
  do{
    delayMicroseconds(10);                      //Eliminate errors
    micVal=myMax.micValue();
  }while( micVal < 700 || micVal == -1 ); //If the sound is -1 or less than 700,it is misjudged.
  i=!i;
  return;
 }
 void setup() {

 myMax.begin();
  Serial.begin(9600);
           }
 void loop() {
  MicVal();    //The function of calling the sound sensor, and exit the function only when there is a clapping sound.
 if(i==0){                 //If the flag is 1, MAX moves forward, and the emoticon panel displays a blue smiley face.
    myMax.forward(150,150);
    myMax.showFace(8, 5);
  }
    else{
      myMax.backward(150,150); //Otherwise MAX moves backward, and the emoticon panel displays a green question mark.
      myMax.showFace(7, 3);
    }
 }

Click to watch: Video demo

Take the Drunkard MAX Home

Click and download Max library file. How to install a library?

 /*
 * @The function of the program: take the drunkard MAX home
 * @The experimental phenomena: MAX get drunk, run randomly, make all kinds of strange emoticons, and emit a variety of whines and screams.
 * The ultrasound eye of MAX is still not blurred. When he sees the obstacle, he will go to the other side. Faced with the drunkard MAX, are you sure that you can take him home?
 * @author [liulihua](lihua.liu@dfrobot.com)
 * @version  V1.0
 * @date  2017-11-30
 */
 #include <DFRobot_MAX.h>    //Load MAX library
  DFRobot_MAX myMax;
 int u;                 // u for ultrasonic distance
 int r;                 // r for storing random numbers
 long timeMode=0;       //Store system uptime
 void setup() {
  myMax.begin();             //Initialize MAX system
 }
 void loop(){
  u=myMax.distanceValue();           //Read the ultrasonic distance
  if(u > 40){                        //Determine whether there is an obstacle ahead.
    if(millis()-1000 > timeMode)     //System time is triggered once every 1 second.
    {
      timeMode=millis();
      r=random (1, 10);             //Generate a random number
      if(r<6){                      //If the random number is less than 6, turn left.
        myMax.forward(75,150);
        myMax.showFace(1,2);         //Emoticon panel displays expression NO.1 and color NO.2.
      }else{                         //Or else, turn right.
        myMax.forward(150,75);
        myMax.showFace(3,6);        //Emoticon panel displays expression NO.3 and color NO.6.
      }
    }
  }

  else                      //If the distance is less than 40cm and there is an obstacle ahead.
  {
     r=random (1, 10);     // Generate a random number again.
     if(r<6)               //If the random number is less than 6, lean left.
     {
       myMax.forward(0,150);
       myMax.playSound(14);
       myMax.showFace(6,4);
       delay(850);
     }
     else                  //If the random number is more than 6, lean right.
     {
       myMax.forward(150,0);
       myMax.playSound(15);
       myMax.showFace(5,7);
       delay(850);
     }
  }

 }

Click to watch: Video demo

Infrared Remote Control Robot

Click and download Max library file. How to install a library?

Click to download infrared library file. How do I install a library?

    /*
     * @The function of the program: infrared remote Control(Use the DFR0107 IR kit and connect the IR sensor to the DP1 port)
     * @The experimental phenomena: control MAX's movement according to the matching of different infrared codes. Any infrared remote controller is acceptable here.  You have to check the code of the corresponding button in the serial port print window before using.
     * @author [liulihua](lihua.liu@dfrobot.com)
     * @version  V1.0
     * @date  2017-12-1
     */
     #include <DFRobot_MAX.h>        //Load MAX library
     #include <IRremote.h>            //Load infrared library
     DFRobot_MAX myMax;
     IRrecv irrecv(DP1);              //Define the infrared receiving port as DP1
     unsigned long IRVal;                 //For storing infrared code
     void setup() {
      myMax.begin();
      Serial.begin(9600);
      irrecv.enableIRIn();            // Start infrared reception
     }
     void loop() {
      IRrecv irrecv(DP1);
      decode_results results;
      IRVal=results.value;                //Assign infrared code to variable IRVal
      if (irrecv.decode(&results)) {   //Print the code if the infrared code is valid.
        Serial.println(IRVal);
        irrecv.resume();
      }
      switch (IRVal)                       //Let MAX perform different actions based on different code values.
      {
      case 16613503: myMax.forward(150,150); break;  //Press VOL , MAX moves forward.
      case 16617583: myMax.backward(150,150);break;  //Press VOL-, MAX moves backword.
      case 16589023: myMax.forward(70,150);  break;  //Press left key, MAX turns left.
      case 16605343: myMax.forward(150,70);  break;  //Press right key, MAX turns right.
      case 16580863: myMax.forward(0,0);     break;  //Press end key, MAX stops.
      }
     }

Click to watch: Video demo

MAX Special Function Set

Max Library File

Function description: the file must be loaded. These two statements are essential to write program on MAX.

    #include <DFRobot_MAX.h>
     DFRobot_MAX myMax;
     例: #include <DFRobot_MAX.h>  //Load into the Max drive library
          DFRobot_MAX myMax;      //Load into Max drive function
         void setup() {
         myMax.begin();
         }
         void loop() {

        }

Initialize the MAX System

Function description: this program is used to initialize MAX program, and you must write it in the setup every time you use MAX for programming.

The prototype of the function: myMax.begin();

For example:

void setup() {
      myMax.begin();         //Initialize MAX
      Serial.begin(9600);    //Initialize the serial port
      }

Control the Car to Move Forward

Function description: control the car’s left and right wheel to move forward. The speed of the left and right wheels can be set.

Parameters:

Left speed: left wheel speed, the value is 0~255

Right speed: right wheel speed, the value is 0~255

Return value: none

The prototype of the function: myMax.forward(leftSpeed,rightSpeed);

For example:

myMax.forward(100,150); //Let MAX move forward at the speed of 100 on the left wheel and 150 on the right wheel.

Control the Car to Move Backward

Function description: control the car’s left and right wheel to move backward. The speed of the left and right wheels can be set.

Parameters:

Left speed: left wheel speed, the value is 0~255

Right speed: right wheel speed, the value is 0~255

Return value: none

The prototype of the function: myMax.backward(leftSpeed,rightSpeed);

For example:

myMax.backward(100,150); //Let MAX move backward at the speed of 100 on the left wheel and 150 on the right wheel.

Play Sound Effects

Function description: play 16 built-in sound effects

Parameters:

Data type: int

Range of values: 1~16, code 16 different sound effects

Return value: none

The prototype of the function: myMax.playSound(i);

For example:

myMax.playSound(5); //Play the sound with the sequence number 5, and the sound effect is the music score suo

Pattern Display on Emoticon Panel

Function description: display built-in emoticons in emoticon panel

Parameters:

i: The value range is 0~22, the int type represents 23 different patterns respectively

Color: the range is 1~7, int type, represent 7 colors

The prototype of the function: myMax.showFace(i,color);

For example:

myMax.showFace(2,3); //Set the emoticon panel to display the emoticon pattern of sequence number 2 with yellow.

Clear Patterns

Function description: clear the pattern displayed by the emoticon panel

Parameters: none

Return value: none

The prototype of the function: myMax.clearScreen();

For example:

myMax.showFace(2,3);//Set the emoticon panel to display pattern.
myMax.clearScreen();//Clear patterns

Display Custom Emoticon Panel Pattern

Function description: display a custom emoticon pattern

Parameters:

Myface: customize the array name that displays the emoticon, static int8_t type.

Color: the range of Values 1~7, int type, represent 7 colors.

Return value: none

The prototype of the function: myMax.customFace(myFace,color);

For example:

 static int8_t myFace[129]{        //Display custom emoticon panel dot matrix
    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //0
        0,1,1,1,1,1,0,0,0,0,1,1,1,1,1,0, //1
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //2
        0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, //3
        0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0, //4
        0,0,0,0,1,0,0,0,0,0,0,1,0,0,0,0, //5
        0,0,0,0,1,0,1,0,0,1,0,1,0,0,0,0, //6
        0,0,0,0,0,1,1,1,1,1,1,0,0,0,0,0, //7
 };

 myMax.showFace(myFace,3);//Display a custom pattern with yellow.

Read the Ultrasound Distance

Function description: read the value of the ultrasonic sensor, unit cm

Parameters: none

Return value: int, distance value, unit cm

The prototype of the function: myMax.distanceValue();

For example:

int a;
a=myMax.distanceValue(); //Read the value of the ultrasonic distance and assign it to the variable a

Read the Value of the Sound Sensor

Function description: read the value of the sound sensor

Parameters: none

Return value: Int 0~1024, the larger in sound, the greater in value

The prototype of the function: myMax.micValue();

For example:

int a;
a=myMax.micValue();//Read the value of the sound sensor and assign it to the variable a

Read the values of Three Line-tracking Sensors

Function description: read the values of three line-tracking sensors

Parameters: i: For the serial number of the line-tracking head, 0 for the right line-tracking sensor, 1 for the middle sensor, 2 for the left sensor

Return value: 0 or 1; the black line returns 1 and the sensor indicator light is on. White returns 0, the sensor indicator light is off.

The prototype of the function: myMax.lineValue(i);

For example:

int l,c,r;
l=myMax.lineValue(2);    //Read the value of the left line-tracking sensor
c=myMax.lineValue(1);    //Read the value of the middle line-tracking sensor
r=myMax.lineValue(0);    //Read the value of the right line-tracking sensor

Digital Port DP

Function description: digital port, 3 analog ports, DP1, DP2, DP3; the occupied pins are 10, 9, 8 respectively.

DP1, DP2, DP3

For example:

void setup(){
             pinMode(DP1, INPUT);  //DP1 is set as an input pin
            }

void loop() {
             val = digitalRead(DP1); // Read the value of DP1, and assign it to val
        }

Analog Port AP

Function description: analog port, 3 analog ports, AP1, AP2, AP3, the occupied pins are A7, A6, A5 respectively.

AP1、AP2、AP3

For example:

void loop() {
             int val = 0;
             val=analogRead(AP1);   //Read  the input analog port AP1 and assign the value to val
             Serial.println(val);   //Print out the analog value on the serial port
            }

Servo Port SP

Function description: dedicated servo port, independent power supply, 3 dedicated servo ports, SP1, SP2, SP3; the occupied pins are 18, 14, 11 respectively.

SP1、SP2、SP3

For example:

myMax.servoControl(SP1, 90)  //Function of servo control
//The above program indicates that the servo is connected to the SP1 port and the servo angle is set to 90 degrees.

If you want to know other useful functions of the servo, please click the link to find more pertinent information:servo

Line-tracking Light

Function description: two states, on or off, the corresponding parameter is 0 or 1

Parameters: 0 or 1

Return value: none

The prototype of the function: myMax.lineLED(i)

For example:

myMax.lineLED(1);//Turn on the line-tracking light.
myMax.lineLED(0);//Turn off the line-tracking light.

Onboard RGB Light

Function description: control four onboard RGB lights

Parameter:

Num: the serial number of the RGB light is 0~3

r: the value of red the range of values uint8 0~255

g: the value of green the range of values uint8 0~255

b: the value of blue the range of values uint8 0~255

Return value: none

The prototype of the function: myMax.rgbLed(uint8_t num, uint8_t r, uint8_t g, uint8_t b)

For example:

myMax.rgbLed(2, 160, 32, 240);
//The above program indicates that the color of the 2nd RGB light will become purple when it is mixed according to the parameters of red 160, green 32, and blue 240.

Onboard Button

Function description: get pressed state of the onboard button

Parameters: none

Return value: 0 or 1, 0 means the button is pressed, 1 means the button is unpressed

The prototype of the function: myMax.buttonValue()

For example:

int a;
a=myMax.buttonValue();
//The above program shows that it gets the state of the button and saves it in the variable a

Servo Control

Function description: control the angle of the servo

Parameter:

Io: IO port connected to the servo, the values are: SP1, SP2, SP3;

Angle: the rotation angle of the servo, ranging from 0 to 180 degrees;

Return value: none

The prototype of the function: myMax.servoControl(uint8_t io, uint8_t angle)

For example:

myMax.servoControl(SP1, 90)
//The above program indicates that the servo is connected to the SP1 port and its angle is set to 90 degrees.

Motor Control

Function description: control motor's movement;

Parameter:

direction_l is the motion mode of the left motor, and speed_l is the speed of the left motor;

direction_r is the motion mode of the right motor, and speed_r is the speed of the right motor;

Speed_l and speed_r range: 0~255 Return value: none

The prototype of the function: myMax.swerve(uint8_t direction_l, uint8_t speed_l, uint8_t direction_r, uint8_t speed_r)

For example:

myMax.swerve(ADVANCE_L, 140, RETREAT_R, 140);
//Left motor moves forward, and its speed is 140; right motor moves backward, its speed is 140

Motor Stop

Function description: control the drive motor to stop rotating;

Parameter: none Return Value: none

The prototype of the function: myMax.stopMotor()

For example:

myMax.stopMotor(); //Control the motor of the both sides to stop rotating.

Light Sensor

Function description: read the value of the light sensor

Parameters: 0 or 1, 0 for the left light sensor and parameter 1 for the right light sensor

Return value: int 0~1024

The prototype of the function: myMax.lightValue(uint8_t num)

For example:

int a,b;
a = myMax.lightValue(0)  //Read the value of the left light sensor and assign it to a
b = myMax.lightValue(1)  //Read the value of the right light sensor and assign it to b

MAX Emoticon Board Pattern and Color List

MAX Emoticon Board Pattern List

The use method of emoticon display function:

myMax.showFace (emoticon number 0-22, color number 1-7);

For example:

myMax.showFace(22,3);//Show the 22nd emoticon with yellow

Face01.png

Emoticons Color List

1. Red

2. Green

3. Yellow

4. Blue

5. Purple

6. Cyan

7. White

For example: to display the 12th expression with blue, you should write:

Mymax.showface (12,4);

MAX Built-in Sound Effects List

Sound effect calling method: myMax.playSound(i); i is the serial number of the sound effect, from 1st to 16th.

Sound effects List:

1: do

2: re

3: mi

4: fa

5: suo

6: la

7: xi

8: high syllable do

9: brake sound

10: spring-back sound

11: two tones of shotting bullets

12: an echo of a long tone

13: Yo Ho

14: cute ending sound

15: wa ou

16: robot talking

Use the 15th "Wa ou" sound effect:

myMax.playSound(15);

Restore MAX Factory Firmware

After downloading the factory program and necessary library files of MAX, extract the zip file. Then you have to open the "DFRobot-MAX-master" folder, find the factory program (pictured), and open the folder and upload the program to MAX. By doing so, you have restored the factory settings.

出厂固件.png

Download Address: Max's factory program and the necessary library files

FAQ (Frequently Asked Questions) :

Q&A Some general Arduino Problems/FAQ/Tips
Q When uploading, there is always an upload project error. why?
A Generally, when uploading a project, it should be in the case of power failure; if the power switch has been turned off and you still failed to upload project, then you should check if the serial port is connected.
Q Must the Bluetooth control of the serial port baud rate be set to 115200?
A Yes, because the baud rate for mobile Bluetooth is set to 115200 by default.
Q why can’t MAX play 16th sound effect in the factory program?
A There are only 15 sound effects in the factory program. The sound effect of 8th high syllable does not exist.
Q Why does Max deviate from the map when he makes a turn in line-tacking ?
A All of the line-tracking program associated with Max are tested with sufficient power. If Max is in a state of deviation in the course of the line-tracking, it indicates that the power is not sufficient, as a result, the spinning speed of the wheels is not enough. Now you need to adjust the speed of two wheels by replacing the battery.
Q How long does 4 batteries last?
A Pro-Test, doing line-tracking movement all the time with new batteries, MAX can keep running for about two hours.
Q Is there any difference between the left and right when connecting the motor?
A Yes, turn MAX back to yourself. Connect the left motor to the M1 interface, the right motor to the M2 interface. If the connection is reversed, MAX will move backward when you press the forward button.

For any questions, advice or cool ideas to share, please visit the DFRobot Forum.

More Documents

DFshopping_car1.png Get Explorer MAX Robot_SKU_ROB0137 from DFRobot Store or DFRobot Distributor.

Turn to the Top