# Error: 'serial' does not name a type

**URL:** <https://forum.arduino.cc/t/error-serial-does-not-name-a-type/1108557>\
**Category:** Programming\
**Created:** [March 29, 2023, 6:38pm UTC](https://forum.arduino.cc/t/error-serial-does-not-name-a-type/1108557 "2023-03-29T18:38:25Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![nikaa\_15](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/nikaa_15/32/939354_2.png) [@nikaa\_15](https://forum.arduino.cc/u/nikaa_15)\
**Post date:** [March 29, 2023, 6:38pm UTC](https://forum.arduino.cc/t/error-serial-does-not-name-a-type/1108557/1 "2023-03-29T18:38:25Z")

</div>

Hi all  
im using arduino uno and L293D(motor driver shield) and this error appears when im verifying could someone help me?

here is code:  
#include "L293D.h"  
/\*  
#include \<Servo.h\>  
Servo myservo;  
\*/

char dataIn='S';  
char determinant;  
char det;  
int vel = 200; //Bluetooth Stuff

int overdrive = 13; //Press Toggle Switch #1, the pin13 LED will light up

void setup()

motor.attach(2, 3, 4, 5);

Serial.begin(9600);md.init();

/\*  
myservo.attach(6);delay(100);  
myservo.write(90);delay(100);  
\*/

void loop(){ det = check(); // You'll need to reconstruct this if your not using the Pololu Dual VNH5019

```
 while (det == 'F') // F, move forward

```

{  
motor.setSpeeds(vel, vel);  
det = check();  
}

while (det == 'B') // B, move back  
{  
motor.setSpeeds(-vel, -vel);  
det = check();  
}

while (det == 'L') // L, move wheels left  
{  
motor.setSpeeds(-vel, vel);  
det = check();  
}

while (det == 'R') // R, move wheels right  
{  
motor.setSpeeds(vel, -vel);  
det = check();  
}

while (det == 'I') // I, turn right forward  
{  
motor.setSpeeds(vel, vel / 2);  
det = check();  
}

while (det == 'J') // J, turn right back  
{  
motor.setSpeeds(-vel, -vel / 2);  
det = check();  
}

while (det == 'G') // G, turn left forward  
{  
motor.setSpeeds(vel / 2, vel);  
det = check();  
}

while (det == 'H') // H, turn left back  
{  
motor.setSpeeds(-vel / 2, -vel);  
det = check();  
}

while (det == 'S') // S, stop  
{  
motor.setSpeeds(0, 0);  
det = check();  
}

```
  //---------------------Toggle switch code------------------//
  /*while (det == 'W'){myservo.write(180);delay(100);det = check();} 
  while (det == 'w'){myservo.write(90);delay(100);det = check();} 
   
  while (det == 'U'){myservo.write(0);delay(100);det = check();} 
  while (det == 'u'){myservo.write(90);delay(100);det = check();} 
  */

```

}

char check()  
{  
if (Serial.available() \> 0)  
{  
char dataIn = Serial.read();  
return dataIn;  
}  
else  
{  
return 'S'; // default to stop if no data received  
}  
}

here are errors:  
C:\Users\User\AppData\Local\Temp.arduinoIDE-unsaved2023229-8236-1w1t94e.qjp1\sketch\_mar29a\sketch\_mar29a.ino:15:1: error: expected initializer before 'motor'  
motor.attach(2, 3, 4, 5);  
^ ~~~~  
C:\Users\User\AppData\Local\Temp.arduinoIDE-unsaved2023229-8236-1w1t94e.qjp1\sketch\_mar29a\sketch\_mar29a.ino:16:1: error: 'Serial' does not name a type  
Serial.begin(9600);md.init();  
^ ~~~~~  
C:\Users\User\AppData\Local\Temp.arduinoIDE-unsaved2023229-8236-1w1t94e.qjp1\sketch\_mar29a\sketch\_mar29a.ino:16:20: error: 'md' does not name a type  
Serial.begin(9600);md.init();

---

<div class="post-metadata">

**Author:** ![jfjlaros](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/jfjlaros/32/716915_2.png) [@jfjlaros](https://forum.arduino.cc/u/jfjlaros)\
**Post date:** [March 29, 2023, 6:49pm UTC](https://forum.arduino.cc/t/error-serial-does-not-name-a-type/1108557/2 "2023-03-29T18:49:02Z")

</div>

> [@nikaa\_15](#):
>
> void setup()

Where are the curly braces (`{}`)?

Perhaps try the following:

```cpp
void setup() {
  motor.attach(2, 3, 4, 5);
  Serial.begin(9600);
  md.init();
}

```

Furthermore, neither `motor` nor `md` are defined.

---

<div class="post-metadata">

**Author:** ![groundFungus](https://avatars.discourse-cdn.com/v4/letter/g/73ab20/32.png) [@groundFungus](https://forum.arduino.cc/u/groundFungus)\
**Post date:** [March 29, 2023, 6:51pm UTC](https://forum.arduino.cc/t/error-serial-does-not-name-a-type/1108557/3 "2023-03-29T18:51:18Z")

</div>

**[Read the forum guidelines](https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum/679966#posting-code-and-common-code-problems)** to see how to properly post code and some good information on making a good post.

Use[the IDE autoformat tool (ctrl-t or Tools, Auto format)](https://www.tutorialspoint.com/auto-format-code-in-arduino-ide) before posting code in code tags. Auto-format will show the missing curly brackets of the setup() function.

Please go back and **fix your original post**.

> [@nikaa\_15](#):
>
> here are errors:  
> error: 'Serial' does not name a type  
> error: 'md' does not name a type

Please post the entire error message(s). Paraphrasing leaves out important information. Copy the entire error message and paste into a post.

---

<div class="post-metadata">

**Author:** ![gcjr](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/gcjr/32/314015_2.png) [@gcjr](https://forum.arduino.cc/u/gcjr)\
**Post date:** [March 29, 2023, 6:56pm UTC](https://forum.arduino.cc/t/error-serial-does-not-name-a-type/1108557/4 "2023-03-29T18:56:24Z")

</div>

where are `motor` and `md` defined?

---

<div class="post-metadata">

**Author:** ![groundFungus](https://avatars.discourse-cdn.com/v4/letter/g/73ab20/32.png) [@groundFungus](https://forum.arduino.cc/u/groundFungus)\
**Post date:** [March 29, 2023, 6:58pm UTC](https://forum.arduino.cc/t/error-serial-does-not-name-a-type/1108557/5 "2023-03-29T18:58:31Z")

</div>

Where did you get the L293D.h library? Did you run library examples to see how to use the library?

---

<div class="post-metadata">

**Author:** ![nikaa\_15](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/nikaa_15/32/939354_2.png) [@nikaa\_15](https://forum.arduino.cc/u/nikaa_15)\
**Post date:** [March 29, 2023, 7:01pm UTC](https://forum.arduino.cc/t/error-serial-does-not-name-a-type/1108557/6 "2023-03-29T19:01:52Z")

</div>

i updated

---

<div class="post-metadata">

**Author:** ![nikaa\_15](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/nikaa_15/32/939354_2.png) [@nikaa\_15](https://forum.arduino.cc/u/nikaa_15)\
**Post date:** [March 29, 2023, 7:02pm UTC](https://forum.arduino.cc/t/error-serial-does-not-name-a-type/1108557/7 "2023-03-29T19:02:45Z")

</div>

yes i runned actually. library in arduino ide 2.0.5

---

<div class="post-metadata">

**Author:** ![nikaa\_15](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/nikaa_15/32/939354_2.png) [@nikaa\_15](https://forum.arduino.cc/u/nikaa_15)\
**Post date:** [March 29, 2023, 7:05pm UTC](https://forum.arduino.cc/t/error-serial-does-not-name-a-type/1108557/8 "2023-03-29T19:05:14Z")

</div>

oh, right i forgot ill add to code and try again,thanks

---

<div class="post-metadata">

**Author:** ![nikaa\_15](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/nikaa_15/32/939354_2.png) [@nikaa\_15](https://forum.arduino.cc/u/nikaa_15)\
**Post date:** [March 29, 2023, 7:06pm UTC](https://forum.arduino.cc/t/error-serial-does-not-name-a-type/1108557/9 "2023-03-29T19:06:02Z")

</div>

yes i forgot to type define,thanks

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/system/32/1140315_2.png) [@system](https://forum.arduino.cc/u/system)\
**Post date:** [September 25, 2023, 7:06pm UTC](https://forum.arduino.cc/t/error-serial-does-not-name-a-type/1108557/10 "2023-09-25T19:06:49Z")

</div>

Closed on September 25, 2023, 7:06pm UTC

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.
