error with liquidcrystal_i2c library

hello,
I am making a drink maker thing and while I was coding it I error checked it and I got this error:

exit status 1
'lcd' does not name a type

and here is my code so far:

#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16 ,2);
const int clk = 2;
const int dt = 3;
int counter = 0;
 int currentStateclk;
 int lastStateclk;
int pumpTime = 0;
const int pump = 7;
const int button = 6;
int buttonstate = 0;
const int led = 5;
void setup()
{
  pinMode(clk,INPUT);
  pinMode(dt,INPUT);
  pinMode(led, OUTPUT);
  pinMode(button, INPUT);
  lcd.init();
  lastStateclk = digitalRead(clk);
}
void loop()
{
    pumpTime = counter/10;
    buttonstate = digitalRead(button);
    if (8 == HIGH){
currentStateclk = digitalRead(clk);
if (currentStateclk != lastStateclk  && currentStateclk == 1){
        if (digitalRead(dt) != currentStateclk);
         {
      counter --;
      counter = counter - 9;
      if (counter<0)
        counter=0;
         }
    } else {
              counter ++;
      counter = counter + 9;
      if (counter>1000)
        counter=1000;
    }
}
}
lcd.setCursor(1,0);
lcd.backlight();
lcd.print("How much do you want?");
lcd.setCursor(2,1);
lcd.print(counter);
if(buttonstate == HIGH && digitalRead pump == LOW){
    digitalRead(pump, HIGH);
    delay(pumpTime);
    digitalWrite(pump, LOW);
}

Use the autoformat feature of the IDE and you will see the issue. The following lines of code are outside any function:

lcd.setCursor(1, 0);
lcd.backlight();
lcd.print("How much do you want?");
lcd.setCursor(2, 1);
lcd.print(counter);
if (buttonstate == HIGH && digitalRead pump == LOW) {
  digitalRead(pump, HIGH);
  delay(pumpTime);
  digitalWrite(pump, LOW);
}

thank you so much it worked!

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