# Console gives "'lcd' does not name a type" after verifying code

**URL:** <https://forum.arduino.cc/t/console-gives-lcd-does-not-name-a-type-after-verifying-code/1464142>\
**Category:** Programming\
**Created:** [October 17, 2026, 8:03pm UTC](https://forum.arduino.cc/t/console-gives-lcd-does-not-name-a-type-after-verifying-code/1464142 "2026-10-17T20:03:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![flinmcguffin](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/flinmcguffin/32/1287350_2.png) [@flinmcguffin](https://forum.arduino.cc/u/flinmcguffin)\
**Post date:** [October 17, 2026, 8:03pm UTC](https://forum.arduino.cc/t/console-gives-lcd-does-not-name-a-type-after-verifying-code/1464142/1 "2026-10-17T20:03:10Z")

</div>

I've been trying to make my code display a message if a condition is met, everything else is working well and I have plugged everything according to order but it tells me that lcd does not name any type, so far I've been told to put "lcd" besides the parenthesis of the "liquid crystal" line and switch the line to the setup loop, but the error still shows up, anyone got any idea what this could entail and how to fix it?

```arduino
#include <Servo.h>
#include <LiquidCrystal.h>
#define echo 6
#define trig 7 
//lcd
#define lcd_E 8
#define lcd_4 10
#define lcd_5 11
#define lcd_6 12
#define lcd_7 13
#define lcd_RS 5
LiquidCrystal lcd(lcd_RS, lcd_E, lcd_4, lcd_5, lcd_6, lcd_7);
Servo servo;
float duration, distance;
void setup() {
  // put your setup code here, to run once:
  lcd.begin(16, 2);
  pinMode(trig, OUTPUT);
  pinMode(echo, INPUT);
  pinMode(9, OUTPUT);
  Serial.begin(9600);
  servo.attach(9);
}

void loop() {
  // Print a message to the LCD.
  // put your main code here, to run repeatedly:
  Sonic();
  if (distance < 10) {
    wave();
    Sonic();
    lcd.print("hello, world!");
  } else {
    servo.write(150);
    lcd.print("waiting...");
  }
}

void Sonic() {
  digitalWrite(trig, LOW);
  delayMicroseconds(2);
  digitalWrite(trig, HIGH);
  delayMicroseconds(10);
  digitalWrite(trig, LOW);

  duration = pulseIn(echo, HIGH);
  distance = (duration * .0343) / 2;
  Serial.print("Distance: ");
  Serial.println(distance);
  delay(100);
}

void wave() {
  Serial.println("waving");
  servo.write(0);
  delay(100);
  servo.write(90);
  delay(100);
}

```

---

<div class="post-metadata">

**Author:** ![UKHeliBob](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/ukhelibob/32/215663_2.png) [@UKHeliBob](https://forum.arduino.cc/u/UKHeliBob)\
**Post date:** [October 17, 2026, 8:06pm UTC](https://forum.arduino.cc/t/console-gives-lcd-does-not-name-a-type-after-verifying-code/1464142/2 "2026-10-17T20:06:53Z")

</div>

Welcome to the forum

Please post the full error message copied from the IDE using the button provided for the purpose. When you post it please use code tags

The sketch compiles OK for me

---

<div class="post-metadata">

**Author:** ![flinmcguffin](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/flinmcguffin/32/1287350_2.png) [@flinmcguffin](https://forum.arduino.cc/u/flinmcguffin)\
**Post date:** [October 17, 2026, 8:10pm UTC](https://forum.arduino.cc/t/console-gives-lcd-does-not-name-a-type-after-verifying-code/1464142/3 "2026-10-17T20:10:28Z")

</div>

Hello, I just realized the reason the code was failing was because I was loading up an older copy by accident, my apologies, I will keep in mind to submit the error for next time, thank you for your help.

---

<div class="post-metadata">

**Author:** ![ivan6000](https://avatars.discourse-cdn.com/v4/letter/i/22d042/32.png) [@ivan6000](https://forum.arduino.cc/u/ivan6000)\
**Post date:** [October 17, 2026, 8:13pm UTC](https://forum.arduino.cc/t/console-gives-lcd-does-not-name-a-type-after-verifying-code/1464142/4 "2026-10-17T20:13:35Z")

</div>

pls mark as solution

---

<div class="post-metadata">

**Author:** ![flinmcguffin](https://dub1.discourse-cdn.com/arduino/user_avatar/forum.arduino.cc/flinmcguffin/32/1287350_2.png) [@flinmcguffin](https://forum.arduino.cc/u/flinmcguffin)\
**Post date:** [October 17, 2026, 8:15pm UTC](https://forum.arduino.cc/t/console-gives-lcd-does-not-name-a-type-after-verifying-code/1464142/5 "2026-10-17T20:15:00Z")

</div>

will do, thank you
