I have a simple code with a servo but it keeps saying expected unqualified-id before '.' token

here is the error code part

#include< Servo.h >
Servo.myservo;
void setup(){
pinMode (goodbutton, INPUT);
pinMode (badbutton, INPUT);
Serial.begin(9600);
myservo.attach(3);
}

and here is the error message

C:\Users\fancy\AppData\Local\Temp\.arduinoIDE-unsaved2022911-13580-yyfmh3.c5bg\sketch_oct11a\sketch_oct11a.ino:6:6: error: expected unqualified-id before '.' token
 Servo.myservo;
      ^
C:\Users\fancy\AppData\Local\Temp\.arduinoIDE-unsaved2022911-13580-yyfmh3.c5bg\sketch_oct11a\sketch_oct11a.ino: In function 'void setup()':
C:\Users\fancy\AppData\Local\Temp\.arduinoIDE-unsaved2022911-13580-yyfmh3.c5bg\sketch_oct11a\sketch_oct11a.ino:11:1: error: 'myservo' was not declared in this scope
 myservo.attach(3);
 ^~~~~~~
C:\Users\fancy\AppData\Local\Temp\.arduinoIDE-unsaved2022911-13580-yyfmh3.c5bg\sketch_oct11a\sketch_oct11a.ino:11:1: note: suggested alternative: 'Servo'
 myservo.attach(3);
 ^~~~~~~
 Servo
C:\Users\fancy\AppData\Local\Temp\.arduinoIDE-unsaved2022911-13580-yyfmh3.c5bg\sketch_oct11a\sketch_oct11a.ino: In function 'void loop()':
C:\Users\fancy\AppData\Local\Temp\.arduinoIDE-unsaved2022911-13580-yyfmh3.c5bg\sketch_oct11a\sketch_oct11a.ino:17:37: error: expected ';' before ')' token
 for(idiot = 0,idiot < 180,idiot += 1){
                                     ^
C:\Users\fancy\AppData\Local\Temp\.arduinoIDE-unsaved2022911-13580-yyfmh3.c5bg\sketch_oct11a\sketch_oct11a.ino:21:6: error: could not convert 'delay(10000)' from 'void' to 'bool'
 delay(10000);
 ~~~~~^~~~~~~
C:\Users\fancy\AppData\Local\Temp\.arduinoIDE-unsaved2022911-13580-yyfmh3.c5bg\sketch_oct11a\sketch_oct11a.ino:22:1: error: expected primary-expression before 'for'
 for(idiot = 90,idiot < 90,idiot -= 1){
 ^~~
C:\Users\fancy\AppData\Local\Temp\.arduinoIDE-unsaved2022911-13580-yyfmh3.c5bg\sketch_oct11a\sketch_oct11a.ino:22:1: error: expected ')' before 'for'
C:\Users\fancy\AppData\Local\Temp\.arduinoIDE-unsaved2022911-13580-yyfmh3.c5bg\sketch_oct11a\sketch_oct11a.ino:22:37: error: expected ';' before ')' token
 for(idiot = 90,idiot < 90,idiot -= 1){
                                     ^
C:\Users\fancy\AppData\Local\Temp\.arduinoIDE-unsaved2022911-13580-yyfmh3.c5bg\sketch_oct11a\sketch_oct11a.ino:26:1: error: expected primary-expression before '}' token
 }
 ^
C:\Users\fancy\AppData\Local\Temp\.arduinoIDE-unsaved2022911-13580-yyfmh3.c5bg\sketch_oct11a\sketch_oct11a.ino:26:1: error: expected ';' before '}' token
C:\Users\fancy\AppData\Local\Temp\.arduinoIDE-unsaved2022911-13580-yyfmh3.c5bg\sketch_oct11a\sketch_oct11a.ino:26:1: error: expected primary-expression before '}' token
C:\Users\fancy\AppData\Local\Temp\.arduinoIDE-unsaved2022911-13580-yyfmh3.c5bg\sketch_oct11a\sketch_oct11a.ino:26:1: error: expected ')' before '}' token
C:\Users\fancy\AppData\Local\Temp\.arduinoIDE-unsaved2022911-13580-yyfmh3.c5bg\sketch_oct11a\sketch_oct11a.ino:26:1: error: expected primary-expression before '}' token
C:\Users\fancy\AppData\Local\Temp\.arduinoIDE-unsaved2022911-13580-yyfmh3.c5bg\sketch_oct11a\sketch_oct11a.ino:46:1: error: 'serial' was not declared in this scope
 serial.println("cuz then .......");
 ^~~~~~
C:\Users\fancy\AppData\Local\Temp\.arduinoIDE-unsaved2022911-13580-yyfmh3.c5bg\sketch_oct11a\sketch_oct11a.ino:46:1: note: suggested alternative: 'Serial'
 serial.println("cuz then .......");
 ^~~~~~
 Serial

exit status 1

Compilation error: expected unqualified-id before '.' token

if you see some rickroll lryics dont be mad cuz I am gonna rickroll the person wor lost the quiz

Where's the rest of the code?

Looks like there are multiple syntax errors.

Where did you see that ?

well this is my full code
I should make clear that this line of code is to prank my brother as he pranked me so there is a rickroll in it

#include <Servo.h>
#include <SoftwareSerial.h>
int goodbutton = 2;
int badbutton = 4;
int idiot = 0;
Servo.myservo;
void setup(){
pinMode (goodbutton, INPUT);
pinMode (badbutton, INPUT);
Serial.begin(9600);
myservo.attach(3);
}

void loop() {
if(digitalRead(goodbutton) == HIGH){
Serial.println("beep boop beep boop beep boop beep boop");
for(idiot = 0,idiot < 180,idiot += 1){
  myservo.write(idiot);
  delay(10);
}
delay(10000);
for(idiot = 90,idiot < 90,idiot -= 1){
  myservo.write(idiot);
  delay(10);
}
}
if(digitalRead(badbutton) == HIGH){
Serial.println("you are such an idiot that suck so much and nobody likes you");
delay(1000);
Serial.println("get wreck rolled LOL");
delay(1000);
Serial.println("never gonna give you up");
delay(100);
Serial.println("never gonna let you down");
delay(100);
Serial.println("never gonna run around and desert you");
delay(100);
Serial.println("never gonna make you cry");
delay(100);
Serial.println("never gonna say goodbye");
delay(100);
Serial.println("never gonna tell a lie and hurt you");
delay(1000);
Serial.println("haha and now how are you feeling");
delay(100);
serial.println("cuz then .......");
delay(100);
Serial.println("you know the rules and so do I");
delay(100);
Serial.println("SAY GOODBYE");
}
}

on an online tutorial made by Arduino

Replace the '.' with a ' '...

I think i have found the solution to one of them as the '.' should not be in between 'Servo' and 'myservo'

Syntax errors....

Servo myservo; // No "."

    for (idiot = 0; idiot < 180; idiot += 1) {  // ";' not ","
    for (idiot = 90; idiot < 90; idiot -= 1) {  // ";" not ",".  Note this loop never runs as 90 !< 90
    Serial.println("cuz then .......");  // "S" not "s"
1 Like

The first thing you are tripping over is your line:
Servo.myservo;
This should be;
Servo myservo;
You are creating a C++ class of type Servo named myservo.
You see later it is used as myservo.write(idiot);

I copied you code, made that one change and I still had lots of other errors, I think you have some braces mismatched. But that clears your first hurdle.

  • Wes

but I still got it working tho

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