# Refreshing LCD with different frequency than output

I have a problem, where I want to use a digital output of Arduino at range of 1kHz, but refresh the LCD with 1 Hz.

I don't know how to refresh LCD slower, without effecting the frequency of output number 8.

My code so far:

``````#include <LiquidCrystal.h>
int LM335_pin = 0;

const int rs = 7, en = 6, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

void setup() {

pinMode(8, OUTPUT);
lcd.begin(20, 4);
}

int  Kelvin, Celsius;

void loop() {

while(Celsius<37)   //postaja_4
{
digitalWrite(8, HIGH);   // turn the LED on (HIGH is the voltage level)
delayMicroseconds(500);                       // wait
digitalWrite(8, LOW);    // turn the LED off by making the voltage LOW
delayMicroseconds(500);                          // wait
}

Kelvin = analogRead(LM335_pin) * 0.489;      //
Celsius = Kelvin - 273;

lcd.setCursor(0, 0);
lcd.write(Celsius);
}
``````
• Do you know the blink-without-delay? arduino.cc/en/Tutorial/BlinkWithoutDelay You can try to make two leds blinking at different rates. Then you can for example update the display a few times per seconds independent of the rest of the sketch. You have to change the `while` and give perhaps just one pulse in the loop(). – Jot Sep 13 '18 at 11:04
• Don't use delays like that for outputting a 1kHz square wave. Use PWM instead. – Majenko Sep 13 '18 at 11:14
• Please tell us what the 1kHz at pin 8 is for. Perhaps the arduino function `tone` is good enough. – Jot Sep 13 '18 at 11:24
• pin 8 is used to turn on and off the heater, through the MOSFET. – Jakey Sep 13 '18 at 11:34
• For a heater, the frequency is 1kHz is probably not needed. @Majenko already wrote about pwm. The arduino function for pwm is `analogWrite`: arduino.cc/reference/en/language/functions/analog-io/… – Jot Sep 13 '18 at 12:18