Its saying expected initializer before float, I am just a physics last year graduate doing project. Please help me to work this code

#include <LiquidCrystal.h>

LiquidCrystal lcd(2, 3, 4, 5, 6, 7);

void delay (int delay)

#define echoPin 8 //echo pin

#define trigPin 9 //Trigger pin

float time;

float distance_cm;

float distance_in;

void setup(){

// put your setup code here, to run once:

Serial.begin(9600);

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

lcd.begin(16, 2);

lcd.setCursor(0,0);

lcd.print("Electronic Distance");

lcd.setCursor(0,1);

lcd.print("Measuring Assembly");

delay(1000);

lcd.clear();

}

void loop(){

digitalWrite(trigPin, LOW); //PULSE |---|

delayMicroseconds(2);

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

time = pulseIn(echoPin, HIGH);

distance_cm = (time/2) / 29.1; // distance for centimeter

distance_in = (time/2) / 73.914; // distance for inch

lcd.setCursor(0, 0);

lcd.print("Distance");

lcd.setCursor(0, 1);

lcd.print(distance_cm,1);

lcd.print("cm");

lcd.setCursor(9, 1);

lcd.print(distance_in);

lcd.print("in");

Serial.print("cm=");

Serial.print(distance_cm);

Serial.print("inch=");

Serial.println(distance_in);

Delay(200);

}

No such function.

Unnecessary, and missing a semicolon.

Aren't physics undergrads taught basic literacy anymore?

1 Like

Please edit your post to add code tags ("</>" editor button).

please help me debug this code complete. running compiler is a nightmare

You forgot the ';' at the end of the line.

1 Like

Oh, come on! Grade school kids manage it.

1 Like

Again, this awful lazy cut-and-paste code
I despair

1 Like

i have very basic c++ ed and i even havent practiced it much as i am still going through fundamentals

please give me the instructions to work this code

See post 2

1 Like

ohk

thanks a lot

fixed that

whats the next error

"blissentity" to the ignore list.

1 Like

which post pal?

The one marked "#2".

1 Like

i added the missing ;

now its saying delay was not declared in this scope

No, it isn't.
Read it again.
Carefully.

See post #2

1 Like

I have read it carefully

But I don't understand what should I do now

What characters should i delete and add so that this code will run.

I have my 2nd project pending too

Please just tell the mistakes in this and instructions.

Sorry to disturb

Well, if you're having trouble understanding, post your code, and post the error message.

How can i post the code and message here?

I have already posted the code in post description

Open a set of code tags, paste in the code.
Open another set of code tags, paste in the error message(s)

Pal, i just corrected the last Capital D of delay to small cap and it worked!!!

Thank you so much pal for bearing with me this long. :blush: