How can I fix this problem? :<

I have some problem with this codes.

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include<Servo.h>

LiquidCrystal_I2C lcd;(0X27,16,2);
Servo servo;
int pos = 10;

int trig = 8;
int echo = 9;


int led = A0;

void setup() {
 lcd.begin();
 lcd.backlight();
 
 Serial.begin(9600);
 pinMode(trig, OUTPUT);
 pinMode(echo, INPUT);
 pinMode(led, OUTPUT);
 servo.attach(10);
}

void loop() {
 int angle;
 digitalWrite(trig, LOW);
 digitalWrite(echo, LOW);
 delayMicroseconds(2);
 digitalWrite(trig, HIGH);
 delayMicroseconds(10);
 digitalWrite(trig, LOW);

 unsigned long duration = pulseIn(echo, HIGH);

 float distance = duration / 29.0 / 2.0;

 Serial.print(distance);
 Serial.println("cm");

 if (distance < 10) {
   digitalWrite(led, LOW);
   lcd.print("ACE");
   for(pos =0;pos<30; pos++)
   {
     servo.write(pos);
     delay(300);
   }
 }
 else {
   digitalWrite(led, HIGH);
 }
 delay(200);
}

LiquidCrystal_I2C lcd;(0X27,16,2);
it doesn't work as >no matching function for call to 'LiquidCrystal_I2C::LiquidCrystal_I2C()'<

And I also want to reset the angle of servo motor.

Help me ;(

Semicolon/syntax:
LiquidCrystal_I2C lcd**;**(0X27,16,2);
and also check the parameters just in case (16 and 2).

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html .
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :slight_smile:

TomGeorge:
Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html .
Then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom... :slight_smile:

Oh, I checked your reply so late....I've just edited it. Thanks :slight_smile:

To help you understand why this was the error so you can fix future issues, and to help others who end up here, this is why:

It's the stray semicolon. That marks the end of a statement, so as the compiler sees it,

LiquidCrystal_I2C lcd;

So it assumes that you mean to call the constructor with no arguments, like:

LiquidCrystal_I2C lcd();

Then it reports the error that it does because LiquidCrystal_I2C class only has constructors that take arguments (the I2C address and number of columns and rows, as you intended to) so it reports that it could not find a matching function definition.

Asides:

always post complete errors - parts you didnt realize were important may be a smoking gun for us.

Remember that if you need help, you dont understand the error, and are not qualified to assess which part is important (if you could, you would probably not need to ask us how to fix it). So, provide the full error!

DrAzzy:
To help you understand why this was the error so you can fix future issues, and to help others who end up here, this is why:

It's the stray semicolon. That marks the end of a statement, so as the compiler sees it,

LiquidCrystal_I2C lcd;

So it assumes that you mean to call the constructor with no arguments, like:

LiquidCrystal_I2C lcd();

Then it reports the error that it does because LiquidCrystal_I2C class only has constructors that take arguments (the I2C address and number of columns and rows, in this case) so it reports that it could not find a matching function definition.

Thanks for your help. :> I edit code as your reply LiquidCrystal_I2C lcd(16,2);[code] , but it doesn't work still. ;(

Nobody knows what...

but it doesn't work still

... means.

Post the complete current version of your code. Say what it's supposed to do, what it actually does, and what the discrepancy is.