Help fix code

Hi Everyone,

I've been working on this code for a while but I'm so confused on the errors if anyone can please help me fix the errors I will be forever thankful!

void setup() {
// put your setup code here, to run once:

#define trigpin 8
#define echopin 6
pinMode(trigpin, OUTPUT);
pinMode(echopin, INPUT);

int buttonPin = 8;
int buttonState = 0;

digitalWrite(trigpin, HIGH);
delay(50);
digitalWrite(trigpin, LOW);

unsigned long duration=pulseIn(echopin,HIGH);
int distance=(duration/2)/29.1;

#include <Servo.h>
Servo myservo;

myservo.attach(9);
myservo.writeMicroseconds(50);
myservo.write(90);

int val, potpin = 0;
val = analogRead(potpin);
val = map(val, 0, 1023, 0, 180);

pinMode(buttonPin, INPUT);
digitalWrite(buttonPin, HIGH);

#include <LiquidCrystal.h>
LiquidCrystal lcd (12, 11, 5, 4, 3, 2);
lcd.begin(16, 2);
lcd.clear();
lcd.print("Stay out!");

}

Door_opener.ino (783 Bytes)

Please follow the advice on posting a programming question given in Read this before posting a programming question

In particular note the advice to Auto format code in the IDE and to use code tags when posting code here as it prevents some combinations of characters in code being interpreted as HTML commands such as italics, bold or a smiley character, all of which render the code useless

Please post your code within </> code-tags.

You've put you whole code within setup() and loop() is missing
All the includes & defines should be before any of the function declarations.

Have a look at any of the examples.