'Serial.h' error on Arduino Uno

Hello, I am new to arduino. The code I wrote is supposed to power up an rgb light, electric motor (to create a garage door for a house), security system and IR temperature sensor.

For some reason I keep getting the error:
exit status 1
Compilation error: 'Serial' does not name a type

I have tried to rectify it by adding " #include<Serial.h> "
But this just gives the error:
exit status 1
Compilation error: Serial.h: No such file or directory

I am stuck. Here is my code:::


#include<Servo.h>
Servo myservo;

int count=0;
int pos;

void setup() {
  pinMode(3,OUTPUT);//Blue LED
  pinMode(5,OUTPUT);//Green LED
  pinMode(6,OUTPUT);//Red LED
  pinMode(2,OUTPUT);//Relay-Fan
  Serial.begin(9600);
}

void loop(){
// *******RGB Code********
if(count<10){
  digitalWrite(3,HIGH);//Blue LED
  digitalWrite(5,LOW);
  digitalWrite(6,LOW);
  delay(250);
}

else if(count<20){
  digitalWrite(3,LOW);
  digitalWrite(5,HIGH);//Green LED
  digitalWrite(6,LOW);
}

else if(count<30){
  digitalWrite(3,LOW);
  digitalWrite(5,LOW);
  digitalWrite(6,HIGH);//Red LED
  delay(250);
}

else if(count<40){
  digitalWrite(3,HIGH);
  digitalWrite(5,HIGH);
  digitalWrite(6,HIGH);
  delay(250);
}

else if(count<50){
  count=0;
  }
  count++;

}
  
//---Temp control code-------------
 int tempSensor = analogRead(A0);
 Serial.println(tempSensor);

if(tempSensor<500) {
  digitalWrite(2,HIGH);
}
else {
  digitalWrite(2,LOW);
}
//-----
digitalwrite(6, HIGH):
}
else if (count < 50) {
  count = 0;
}
count++;


//#############Open Garage Door###############
if(digitalRead(10)&&digitalRead(12)){//nothing outside and nothing inside = close door
  goTo(180);
  }
}
else if(!digitalRead(10)&& digitalRead(12)){//something outside and nothing inside 
 goTo(100);}
}
else if(!digitalRead(10) &&!digitalRead(12)){//something outside and inside
 goTo(100);
 }
else if(digitalRead(10) && !digitalRead(12)){//nothing outside and something inside
 goTo(100);
 }

//&&&&&&&&&&&&&&&Security System&&&&&&&&&&&&&&
if(digitalRead(7)==true){//door is open
  digitalWrite(13,LOW);
  tone(11,1000);
  }
  else{ //door is closed 
    digitalWrite(13,HIGH);
    noTone(11);
    }
 //&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
 delay(100);
}
void goTo(int state){//open 100 degrees; close 180 degrees
  if (pos < state) {
    while (pos < state) {
      pos++;
      myservo.write(pos);
      delay(15);
    }
  } else {
    while (pos > state) {
      pos--;
      myservo.write(pos);
      delay(15);
    }
  }
}

Doesn't seem to be in a function

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