problem with temperature regulation

Hi Everyone, I have one problem with temperature regulation.So, the problem is next:
I have two buttons, for plus(counter++) and minus(counter--) and temperature sensor ds18b20. I want to
give temperature with counter by pressing theese two buttons. When i press the button, counter temperature
doesn't change. It must be pressed 10 or 15 times to change. Here is the code:

#include <OneWire.h>
#include <DallasTemperature.h>
#include <LiquidCrystal.h>
#define ONE_WIRE_BUS A0
OneWire oneWire(ONE_WIRE_BUS);
DallasTemperature sensors(&oneWire);
int Celsius;
int button=7;
bool buttonState=false;
int lastState=false;
int counter=0;
LiquidCrystal lcd(12,11,5,4,3,2);

void setup() {
// put your setup code here, to run once:
pinMode(button,INPUT);
lcd.begin(16,2);
lcd.print("Celsius= ");
sensors.begin();

}
void loop() {
// put your main code here, to run repeatedly:
sensors.requestTemperatures();
Celsius=sensors.getTempCByIndex(0);
lcd.setCursor(9,0);
lcd.print(Celsius);
lcd.print(" C");
delay(500);
buttonState=digitalRead(button);
if(buttonState!=lastState){

counter++;
lcd.setCursor(9,1);
lcd.print(counter);

}
delay(5);
buttonState=lastState;

}

You r push button switch has TWO pins. One is connected to pin 7 on your Arduino. Where is the other switch pin connected?

Paul

In every round through your loop() you request the temperatures which waits for the result about 100ms, then you wait another 500ms after printing the temperature to the LCD. Then you check for the button state. That means you have to push the button longer than 0.6s to enable the Arduino to register your button push in every loop(). The DallasTemperature library has an async option, the WaitForConversion2 example shows you how to use the feature.

buttonState=lastState;

Two problems. This is the wrong way round. It should be:

lastState = buttonState;

AND it should be inside the if statement.

Where is the count down button? At the moment you can only increase the counter.

Pete

Yes, i see. Thank you, both of you.