1

I was using a 3rd party programming enviroment, mBlock 3.4.5 for making C++ Arduino programmes with a graphical programming language. I was compiling a program and the following eroor came up.

project_Untitled0_0.ino:65:1: error: 'MeDCMotor' does not name a type
project_Untitled0_0.ino:66:1: error: 'MeDCMotor' does not name a type
project_Untitled0_0.ino: In function 'void move(int, int)':
project_Untitled0_0.ino:85:7: error: 'motor_9' was not declared in this scope
project_Untitled0_0.ino:85:24: error: 'M1' was not declared in this scope
project_Untitled0_0.ino:86:7: error: 'motor_10' was not declared in this scope
'MeDCMotor' does not name a type

I took another look at the program and there were some lines of code that seem they are added in the program by deafult:

MeDCMotor motor_9(9);
MeDCMotor motor_10(10);
void move(int direction, int speed)
{
      int leftSpeed = 0;
      int rightSpeed = 0;
      if(direction == 1){
            leftSpeed = speed;
            rightSpeed = speed;
      }else if(direction == 2){
            leftSpeed = -speed;
            rightSpeed = -speed;
      }else if(direction == 3){
            leftSpeed = -speed;
            rightSpeed = speed;
      }else if(direction == 4){
            leftSpeed = speed;
            rightSpeed = -speed;
      }
      motor_9.run((9)==M1?-(leftSpeed):(leftSpeed));
      motor_10.run((10)==M1?-(rightSpeed):(rightSpeed));
}

Since the program does not recognise the MeDCMotor class the program failed to upload.

I am running Windows 10 home edition on a 64-bit laptop.

Is there a way to remove the lines of code that prevent me from uploading the sketch or are there other ways to solve it?

  • Yes, just remove them, and the lines that refer to them, and so on. Of course they're there for a reason so the program won't do what it's supposed to do. As you have correctly identified, it can't find that class. Perhaps you're missing a #include, perhaps it's not in the library to be included. Hard to tell from the (lack of) detail in the question. – Mark Smith Jan 29 '17 at 14:40
  • The lines of code mentioned above are dedicated toother tipes of robots, that can be programmed with the software and are useless on the Arduino. The lines of code cannot be deleted, beacause the code that is displayed is just for preview. – user29519 Jan 29 '17 at 15:51
  • 1
    You're having trouble with a non-standard piece of software, and you don't even mention what it is. Maybe you can find the files on disk somewhere and edit them there. Otherwise, you'll have to give us a bit more of a clue, I suspect. – Mark Smith Jan 29 '17 at 16:08
1

I looked at some entries in a google search for error: 'MeDCMotor' does not name a type, such as 1, 2, 3 and 4. The first three of those latter four links directly address the question you ask, and none of them answer it clearly, except to suggest re-downloading or re-installing the makeblock library. While the fourth link addresses a “does not name a type” error for another library, rather than for makeblock, it has a relatively clear explanation of the problem for that other library:

So, as supplied, the ArduinoByteBuffer.zip file had a complex set of sub-directories, and the two files ByteBuffer.ccp and ByteBuffer.h were located one level down in: \ArduinoByteBuffers\ByteBuffer\

When I 'installed' the library, it went into the directory:

C:\Documents and Settings\Al\My Documents\Arduino\libraries\ArduinoByteBuffers\ByteBuffer\ByteBuffer.ccp C:\Documents and Settings\Al\My Documents\Arduino\libraries\ArduinoByteBuffers\ByteBuffer\ByteBuffer.h

To solve the problem I moved them up a level to:

C:\Documents and Settings\Al\My Documents\Arduino\libraries\ArduinoByteBuffers\ByteBuffer.ccp C:\Documents and Settings\Al\My Documents\Arduino\libraries\ArduinoByteBuffers\ByteBuffer.h

That seemed to be the key - moving the two files (*.ccp and *.h) out of the subdirectory.

Instead of following ordinary C or C++ library-finding rules, the Arduino IDE copies sets of files into a temporary directory according to its own rules when compiling a sketch. You'll need to move your makeblock library files around to match up with Arduino IDE conventions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.