1

Тема: DS18B20+ЖК-модуль HT1621, 2,4 дюйма (Arduino)

Основная статья - http://rcl-radio.ru/?p=132305

http://forum.rcl-radio.ru/uploads/images/2024/07/26f5c52bd1f1845abf17e8158fae0b58.png

http://rcl-radio.ru/wp-content/uploads/2024/06/%D0%A1%D0%BD%D0%B8%D0%BC%D0%BE%D0%BA-%D1%8D%D0%BA%D1%80%D0%B0%D0%BD%D0%B0-%D0%BE%D1%82-2024-06-30-20-18-29.png

#define LCD_CS    6
#define LCD_WR    7
#define LCD_DATA  8

#define UP  2
#define DW  3
#define SET 4

#define HT1621_BIAS                 0x52                    // 1/3duty 4com
#define HT1621_SYS_DIS              0x00                    // Turn off the oscillator system oscillator and LCD bias generator
#define HT1621_SYS_EN               0x02                    // Turn on the system oscillator
#define HT1621_LCD_OFF              0x04                    // Turn off LCD bias
#define HT1621_LCD_ON               0x06                    // Turn on the LCE bias
#define HT1621_XTAL                 0x28                    // external clock
#define HT1621_RC256                0x30                    // internal clock

#include <EEPROM.h>
#include <OneWire.h>        // http://rcl-radio.ru/wp-content/uploads/2018/07/OneWire.zip
OneWire  ds(11); // Вход датчика 18b20

unsigned long times;
int temp;

void setup() {
  pinMode(LCD_CS, OUTPUT);
  pinMode(LCD_WR, OUTPUT);
  pinMode(LCD_DATA, OUTPUT);
  pinMode(UP,INPUT_PULLUP);
  pinMode(DW,INPUT_PULLUP);
  pinMode(SET,INPUT_PULLUP);
  digitalWrite(LCD_CS,HIGH);
  digitalWrite(LCD_WR,HIGH);
  data_100(HT1621_SYS_EN); // Turn on the system oscillator
  data_100(HT1621_BIAS);   // BIAS 13 4 public ports
  data_100(HT1621_RC256);  // Use RC_256K system clock source, on-chip RC oscillator
  data_100(HT1621_LCD_ON);
  clear_lcd();
}

void loop(){
  if(millis()-times>5000){temp=dsRead(0)*10;times=millis();}
  
  print_lcd(5, 10,false);
  print_lcd(4, temp/100%10,false);
  print_lcd(3, temp/10%10,false);
  print_lcd(2, temp%10,true);
  print_lcd(1, 12,false);
  print_lcd(0, 13,false);

  
  delay(200);
}

void print_lcd(byte raz, byte num, bool dp){
  switch(raz){
    case 0: raz=0;break;
    case 1: raz=2;break;
    case 2: raz=4;break;
    case 3: raz=6;break;
    case 4: raz=8;break;
    case 5: raz=10;break;
    }
  switch(num){
    case 0: data_101(raz,0b1110+dp);data_101(raz+1,0b1011);break;  // 0 
    case 1: data_101(raz,0b0110+dp);data_101(raz+1,0b0000);break;  // 1 
    case 2: data_101(raz,0b1100+dp);data_101(raz+1,0b0111);break;  // 2 
    case 3: data_101(raz,0b1110+dp);data_101(raz+1,0b0101);break;  // 3 
    case 4: data_101(raz,0b0110+dp);data_101(raz+1,0b1100);break;  // 4 
    case 5: data_101(raz,0b1010+dp);data_101(raz+1,0b1101);break;  // 5 
    case 6: data_101(raz,0b1010+dp);data_101(raz+1,0b1111);break;  // 6 
    case 7: data_101(raz,0b1110+dp);data_101(raz+1,0b0000);break;  // 7 
    case 8: data_101(raz,0b1110+dp);data_101(raz+1,0b1111);break;  // 8 
    case 9: data_101(raz,0b1110+dp);data_101(raz+1,0b1101);break;  // 9 
    case 10: data_101(raz,0);data_101(raz+1,0);break;  // пусто
    case 11: data_101(raz,0b0000);data_101(raz+1,0b0100);break;  // -
    case 12: data_101(raz,0b1100);data_101(raz+1,0b1100);break; // градус
    case 13: data_101(raz,0b1000);data_101(raz+1,0b1011);break; // C
    }
  }

void clear_lcd(){for(int a=0;a<=32;a++){data_101(a,0);}}

void data_100(int data){
     digitalWrite(LCD_CS,LOW);
   for(int i = 2; i >=0; i--){
     digitalWrite(LCD_WR,LOW);delayMicroseconds(10);
     digitalWrite(LCD_DATA, (0b100 >> i) & 1); 
     digitalWrite(LCD_WR,HIGH);delayMicroseconds(10);
     } 
   for(int i = 8; i >=0; i--){
     digitalWrite(LCD_WR,LOW);delayMicroseconds(10);
     digitalWrite(LCD_DATA, (data >> i) & 1); 
     digitalWrite(LCD_WR,HIGH);delayMicroseconds(10);
     } 
     delayMicroseconds(10);digitalWrite(LCD_CS,HIGH);
     delayMicroseconds(10);digitalWrite(LCD_WR,LOW);
     delayMicroseconds(10);
  }

void data_101(int addr, int data){
     digitalWrite(LCD_CS,LOW);
   for(int i = 2; i >=0; i--){
     digitalWrite(LCD_WR,LOW);delayMicroseconds(10);
     digitalWrite(LCD_DATA, (0b101 >> i) & 1); 
     digitalWrite(LCD_WR,HIGH);delayMicroseconds(10);
     } 
   for(int i = 5; i >=0; i--){
     digitalWrite(LCD_WR,LOW);delayMicroseconds(10);
     digitalWrite(LCD_DATA, (addr >> i) & 1); 
     digitalWrite(LCD_WR,HIGH);delayMicroseconds(10);
     } 
   for(int i = 0; i <=3; i++){
     digitalWrite(LCD_WR,LOW);delayMicroseconds(10);
     digitalWrite(LCD_DATA, (data >> i) & 1); 
     digitalWrite(LCD_WR,HIGH);delayMicroseconds(10);
     }   
     delayMicroseconds(10);digitalWrite(LCD_CS,HIGH);
     delayMicroseconds(10);digitalWrite(LCD_WR,LOW);
  } 

float dsRead(byte x) {
  byte data_[2], addr[8][8], kol = 0;
  while (ds.search(addr[kol])) {  // поиск датчиков, определение адреса и кол-ва датчиков
    kol++;
  } 
  ds.reset_search();  // Сброс поиска датчика
  ds.reset();         // Инициализация, выполняется сброс шины
  ds.select(addr[x]); // Обращение к датчику по адресу
  ds.write(0x44, 0);  // Измерение температуры с переносом данных в память
  ds.reset();         // Инициализация, выполняется сброс шины
  ds.select(addr[x]); // Обращение к датчику по адресу
  ds.write(0xBE);     // Обращение памяти
  data_[0] = ds.read();// Чтение памяти byte low
  data_[1] = ds.read();// Чтение памяти byte high
  float value = ((data_[1] << 8) | data_[0]) / 16.0; return (float)value; // Расчет температуры и вывод
}   

2

Re: DS18B20+ЖК-модуль HT1621, 2,4 дюйма (Arduino)

Терморегулятор DS18B20+ЖК-модуль HT1621, 2,4 дюйма (Arduino)

http://forum.rcl-radio.ru/uploads/images/2024/07/2b270ce1c7e3e9c6faed24b7f93ba812.png

http://forum.rcl-radio.ru/uploads/images/2024/07/37d46a0024cad2463d5cc2259048e426.png

http://forum.rcl-radio.ru/uploads/images/2024/07/859a3ac823cfbb9cc029f50784061f47.png

#define LCD_CS    6
#define LCD_WR    7
#define LCD_DATA  8

#define UP  2
#define DW  3
#define SET 4

#define OUT_RELE 13

#define HT1621_BIAS                 0x52                    // 1/3duty 4com
#define HT1621_SYS_DIS              0x00                    // Turn off the oscillator system oscillator and LCD bias generator
#define HT1621_SYS_EN               0x02                    // Turn on the system oscillator
#define HT1621_LCD_OFF              0x04                    // Turn off LCD bias
#define HT1621_LCD_ON               0x06                    // Turn on the LCE bias
#define HT1621_XTAL                 0x28                    // external clock
#define HT1621_RC256                0x30                    // internal clock

#include <EEPROM.h>
#include <OneWire.h>        // http://rcl-radio.ru/wp-content/uploads/2018/07/OneWire.zip
OneWire  ds(11); // Вход датчика 18b20

unsigned long times,times1;
int temp,set,reg_ind;
float gis = 0.5, reg;
bool w;

void setup() {
  pinMode(LCD_CS, OUTPUT);
  pinMode(LCD_WR, OUTPUT);
  pinMode(LCD_DATA, OUTPUT);
  pinMode(OUT_RELE, OUTPUT);
  pinMode(UP,INPUT_PULLUP);
  pinMode(DW,INPUT_PULLUP);
  pinMode(SET,INPUT_PULLUP);
  digitalWrite(LCD_CS,HIGH);
  digitalWrite(LCD_WR,HIGH);
  data_100(HT1621_SYS_EN); // Turn on the system oscillator
  data_100(HT1621_BIAS);   // BIAS 13 4 public ports
  data_100(HT1621_RC256);  // Use RC_256K system clock source, on-chip RC oscillator
  data_100(HT1621_LCD_ON);
  clear_lcd();
  reg = EEPROM.read(10);
}

void loop(){
  if(digitalRead(SET)==LOW){set++;if(set > 1){set = 0;}}    
  if(digitalRead(UP)==LOW){reg++;w=1;times1 = millis();if(reg>125){reg=125;}}    
  if(digitalRead(DW)==LOW){reg--;w=1;times1 = millis();if(reg<0){reg=0;}}  

  reg_ind = reg*10;
  if(millis()-times>1000){temp=dsRead(0)*10;times=millis();}

  if(set==0){
  print_lcd(5, 10,false);
  print_lcd(4, temp/100%10,false);
  print_lcd(3, temp/10%10,false);
  print_lcd(2, temp%10,true);
  print_lcd(1, 12,false);
  print_lcd(0, 13,false);
  }
  if(set==1){
  print_lcd(5, 14,false);
  print_lcd(4, reg_ind/100%10,false);
  print_lcd(3, reg_ind/10%10,false);
  print_lcd(2, reg_ind%10,true);
  print_lcd(1, 12,false);
  print_lcd(0, 13,false);
  }  

  if(reg >= float(temp/10.0) + gis){digitalWrite(OUT_RELE,HIGH);}
  if(reg <= float(temp/10.0) - gis){digitalWrite(OUT_RELE,LOW);}

  if(millis()-times1>5000&&w==1){w=0;EEPROM.update(10, reg);}
  
  delay(200);
}

void print_lcd(byte raz, byte num, bool dp){
  switch(raz){
    case 0: raz=0;break;
    case 1: raz=2;break;
    case 2: raz=4;break;
    case 3: raz=6;break;
    case 4: raz=8;break;
    case 5: raz=10;break;
    }
  switch(num){
    case 0: data_101(raz,0b1110+dp);data_101(raz+1,0b1011);break;  // 0 
    case 1: data_101(raz,0b0110+dp);data_101(raz+1,0b0000);break;  // 1 
    case 2: data_101(raz,0b1100+dp);data_101(raz+1,0b0111);break;  // 2 
    case 3: data_101(raz,0b1110+dp);data_101(raz+1,0b0101);break;  // 3 
    case 4: data_101(raz,0b0110+dp);data_101(raz+1,0b1100);break;  // 4 
    case 5: data_101(raz,0b1010+dp);data_101(raz+1,0b1101);break;  // 5 
    case 6: data_101(raz,0b1010+dp);data_101(raz+1,0b1111);break;  // 6 
    case 7: data_101(raz,0b1110+dp);data_101(raz+1,0b0000);break;  // 7 
    case 8: data_101(raz,0b1110+dp);data_101(raz+1,0b1111);break;  // 8 
    case 9: data_101(raz,0b1110+dp);data_101(raz+1,0b1101);break;  // 9 
    case 10: data_101(raz,0);data_101(raz+1,0);break;  // пусто
    case 11: data_101(raz,0b0000);data_101(raz+1,0b0100);break;  // -
    case 12: data_101(raz,0b1100);data_101(raz+1,0b1100);break; // градус
    case 13: data_101(raz,0b1000);data_101(raz+1,0b1011);break; // C
    case 14: data_101(raz,0b0000);data_101(raz+1,0b0110);break; // r
    }
  }

void clear_lcd(){for(int a=0;a<=32;a++){data_101(a,0);}}

void data_100(int data){
     digitalWrite(LCD_CS,LOW);
   for(int i = 2; i >=0; i--){
     digitalWrite(LCD_WR,LOW);delayMicroseconds(10);
     digitalWrite(LCD_DATA, (0b100 >> i) & 1); 
     digitalWrite(LCD_WR,HIGH);delayMicroseconds(10);
     } 
   for(int i = 8; i >=0; i--){
     digitalWrite(LCD_WR,LOW);delayMicroseconds(10);
     digitalWrite(LCD_DATA, (data >> i) & 1); 
     digitalWrite(LCD_WR,HIGH);delayMicroseconds(10);
     } 
     delayMicroseconds(10);digitalWrite(LCD_CS,HIGH);
     delayMicroseconds(10);digitalWrite(LCD_WR,LOW);
     delayMicroseconds(10);
  }

void data_101(int addr, int data){
     digitalWrite(LCD_CS,LOW);
   for(int i = 2; i >=0; i--){
     digitalWrite(LCD_WR,LOW);delayMicroseconds(10);
     digitalWrite(LCD_DATA, (0b101 >> i) & 1); 
     digitalWrite(LCD_WR,HIGH);delayMicroseconds(10);
     } 
   for(int i = 5; i >=0; i--){
     digitalWrite(LCD_WR,LOW);delayMicroseconds(10);
     digitalWrite(LCD_DATA, (addr >> i) & 1); 
     digitalWrite(LCD_WR,HIGH);delayMicroseconds(10);
     } 
   for(int i = 0; i <=3; i++){
     digitalWrite(LCD_WR,LOW);delayMicroseconds(10);
     digitalWrite(LCD_DATA, (data >> i) & 1); 
     digitalWrite(LCD_WR,HIGH);delayMicroseconds(10);
     }   
     delayMicroseconds(10);digitalWrite(LCD_CS,HIGH);
     delayMicroseconds(10);digitalWrite(LCD_WR,LOW);
  } 

float dsRead(byte x) {
  byte data_[2], addr[8][8], kol = 0;
  while (ds.search(addr[kol])) {  // поиск датчиков, определение адреса и кол-ва датчиков
    kol++;
  } 
  ds.reset_search();  // Сброс поиска датчика
  ds.reset();         // Инициализация, выполняется сброс шины
  ds.select(addr[x]); // Обращение к датчику по адресу
  ds.write(0x44, 0);  // Измерение температуры с переносом данных в память
  ds.reset();         // Инициализация, выполняется сброс шины
  ds.select(addr[x]); // Обращение к датчику по адресу
  ds.write(0xBE);     // Обращение памяти
  data_[0] = ds.read();// Чтение памяти byte low
  data_[1] = ds.read();// Чтение памяти byte high
  float value = ((data_[1] << 8) | data_[0]) / 16.0; return (float)value; // Расчет температуры и вывод
}   

3

Re: DS18B20+ЖК-модуль HT1621, 2,4 дюйма (Arduino)

Часы  с будильником ЖК-модуль HT1621, 2,4 дюйма (Arduino)

Установка времени часов кнопки НН ММ
Установка времени будильника - нажать один раз кнопку SET, далее кнопки НН ММ
Al On - будильник активен, Al Off - будильник не активен
Нажать кнопку SET чтобы выключить сигнал будильника при его срабатывании

http://forum.rcl-radio.ru/uploads/images/2024/07/70dfa5d09652fd55c8d981f515977237.png

http://forum.rcl-radio.ru/uploads/images/2024/07/4516ed23bd666e5849f2f8eae7da632d.png

http://forum.rcl-radio.ru/uploads/images/2024/07/27806f374e8d28df3bbef7c4df23c896.png

http://forum.rcl-radio.ru/uploads/images/2024/07/4bfb995fcb79af3efb279f91003cf393.png

http://forum.rcl-radio.ru/uploads/images/2024/07/95756f5c3826459dbde5dbb608f5c030.png

#define LCD_CS    6
#define LCD_WR    7
#define LCD_DATA  8

#define HH  2
#define MM  3
#define SET 4

#define TONE 10


#define HT1621_BIAS                 0x52                    // 1/3duty 4com
#define HT1621_SYS_DIS              0x00                    // Turn off the oscillator system oscillator and LCD bias generator
#define HT1621_SYS_EN               0x02                    // Turn on the system oscillator
#define HT1621_LCD_OFF              0x04                    // Turn off LCD bias
#define HT1621_LCD_ON               0x06                    // Turn on the LCE bias
#define HT1621_XTAL                 0x28                    // external clock
#define HT1621_RC256                0x30                    // internal clock

#include <Wire.h>
#include <DS3231.h> // http://rcl-radio.ru/wp-content/uploads/2022/10/DS3231.zip
#include <EEPROM.h>
  DS3231 clock;
  RTCDateTime DateTime;

unsigned long times,times1;
int hour,minut,secon,temp,set;
int hh_alarm,mm_alarm;
bool w,alarm,on_alarm,ton;

void setup() {
  clock.begin();
  //clock.setDateTime(__DATE__, __TIME__); // Устанавливаем время на часах, основываясь на времени компиляции скетча
  pinMode(LCD_CS, OUTPUT);
  pinMode(LCD_WR, OUTPUT);
  pinMode(LCD_DATA, OUTPUT);
  pinMode(TONE, OUTPUT);
  pinMode(HH,INPUT_PULLUP);
  pinMode(MM,INPUT_PULLUP);
  pinMode(SET,INPUT_PULLUP);
  digitalWrite(LCD_CS,HIGH);
  digitalWrite(LCD_WR,HIGH);
  data_100(HT1621_SYS_EN); // Turn on the system oscillator
  data_100(HT1621_BIAS);   // BIAS 13 4 public ports
  data_100(HT1621_RC256);  // Use RC_256K system clock source, on-chip RC oscillator
  data_100(HT1621_LCD_ON);
  clear_lcd();
  hh_alarm = EEPROM.read(10);
  mm_alarm = EEPROM.read(11);
  alarm = EEPROM.read(12);
}

void loop(){
  DateTime = clock.getDateTime();
  hour = DateTime.hour;
  minut = DateTime.minute; 
  secon = DateTime.second;

 if(ton==0){
  if(digitalRead(SET)==LOW){set++;if(set>2){set=0;}}
  if(digitalRead(HH)==LOW&&set==0){hour++;if(hour>23){hour=0;} clock.setDateTime(2024, 2, 22, hour, minut, 0);} 
  if(digitalRead(MM)==LOW&&set==0){minut++;if(minut>59){minut=0;} clock.setDateTime(2024, 2, 22, hour, minut, 0);} 
  if(digitalRead(HH)==LOW&&set==1){hh_alarm++;w=1;times1 = millis();if(hh_alarm>23){hh_alarm=0;}}    
  if(digitalRead(MM)==LOW&&set==1){mm_alarm++;w=1;times1 = millis();if(mm_alarm>59){mm_alarm=0;}}
  if(digitalRead(HH)==LOW&&set==2){alarm=1;w=1;times1 = millis();}    
  if(digitalRead(MM)==LOW&&set==2){alarm=0;w=1;times1 = millis();} 
 }
 if(ton==1&&digitalRead(SET)==LOW){on_alarm=0;ton=0;delay(200);}

if(set==0){
  if(secon<55){
  if(alarm==0){print_lcd(5, 10,false);}else{print_lcd(5, 11,false);}
  print_lcd(4, hour/10%10,false);
  print_lcd(3, hour%10,false);
  if(millis()-times<500){print_lcd(2, minut/10%10,true);}else{print_lcd(2, minut/10%10,false);}
  print_lcd(1, minut%10,false);
  if(alarm==0){print_lcd(0, 10,false);}else{print_lcd(0, 11,false);}
  if(millis()-times>=1000){times=millis();}
  }
  if(secon>=55){
  temp=clock.readTemperature();
  
  print_lcd(5, 10,false);
  print_lcd(4, temp/10%10,false);
  print_lcd(3, temp%10,false);
  print_lcd(2, 12,true);
  print_lcd(1, 13,false);
  print_lcd(0, 10,false);
  }
}

if(set==1){  
  print_lcd(5, 10,false);
  print_lcd(4, hh_alarm/10%10,false);
  print_lcd(3, hh_alarm%10,false);
  print_lcd(2, mm_alarm/10%10,true);
  print_lcd(1, mm_alarm%10,false);
  print_lcd(0, 10,false);
}

if(set==2 && alarm==1){  
  print_lcd(5, 14,false);
  print_lcd(4, 15,false);
  print_lcd(3, 10,false);
  print_lcd(2, 0,false);
  print_lcd(1, 16,false);
  print_lcd(0, 10,false);
}
if(set==2 && alarm==0){  
  print_lcd(5, 14,false);
  print_lcd(4, 15,false);
  print_lcd(3, 10,false);
  print_lcd(2, 0,false);
  print_lcd(1, 17,false);
  print_lcd(0, 17,false);
}

  delay(200);
  if(millis()-times1>5000&&w==1){w=0;EEPROM.update(10, hh_alarm);EEPROM.update(11, mm_alarm);EEPROM.update(12, alarm);}

  if(alarm==1&&on_alarm==1&&(hour*100+minut==hh_alarm*100+mm_alarm)){ton=1;tone(TONE,1200,500);delay(100);}
  if(hour*100+minut!=hh_alarm*100+mm_alarm){on_alarm=1;ton=0;}
}


 
void print_lcd(byte raz, byte num, bool dp){
  switch(raz){
    case 0: raz=0;break;
    case 1: raz=2;break;
    case 2: raz=4;break;
    case 3: raz=6;break;
    case 4: raz=8;break;
    case 5: raz=10;break;
    }
  switch(num){
    case 0: data_101(raz,0b1110+dp);data_101(raz+1,0b1011);break;  // 0 
    case 1: data_101(raz,0b0110+dp);data_101(raz+1,0b0000);break;  // 1 
    case 2: data_101(raz,0b1100+dp);data_101(raz+1,0b0111);break;  // 2 
    case 3: data_101(raz,0b1110+dp);data_101(raz+1,0b0101);break;  // 3 
    case 4: data_101(raz,0b0110+dp);data_101(raz+1,0b1100);break;  // 4 
    case 5: data_101(raz,0b1010+dp);data_101(raz+1,0b1101);break;  // 5 
    case 6: data_101(raz,0b1010+dp);data_101(raz+1,0b1111);break;  // 6 
    case 7: data_101(raz,0b1110+dp);data_101(raz+1,0b0000);break;  // 7 
    case 8: data_101(raz,0b1110+dp);data_101(raz+1,0b1111);break;  // 8 
    case 9: data_101(raz,0b1110+dp);data_101(raz+1,0b1101);break;  // 9 
    case 10: data_101(raz,0);data_101(raz+1,0);break;  // пусто
    case 11: data_101(raz,0b0000);data_101(raz+1,0b0100);break;  // -
    case 12: data_101(raz,0b1100);data_101(raz+1,0b1100);break; // градус
    case 13: data_101(raz,0b1000);data_101(raz+1,0b1011);break; // C
    case 14: data_101(raz,0b1110);data_101(raz+1,0b1110);break; // A
    case 15: data_101(raz,0b0000);data_101(raz+1,0b1011);break; // l
    case 16: data_101(raz,0b0010);data_101(raz+1,0b0110);break; // n
    case 17: data_101(raz,0b1000);data_101(raz+1,0b1110);break; // F
    }
  }

void clear_lcd(){for(int a=0;a<=32;a++){data_101(a,0);}}

void data_100(int data){
     digitalWrite(LCD_CS,LOW);
   for(int i = 2; i >=0; i--){
     digitalWrite(LCD_WR,LOW);delayMicroseconds(10);
     digitalWrite(LCD_DATA, (0b100 >> i) & 1); 
     digitalWrite(LCD_WR,HIGH);delayMicroseconds(10);
     } 
   for(int i = 8; i >=0; i--){
     digitalWrite(LCD_WR,LOW);delayMicroseconds(10);
     digitalWrite(LCD_DATA, (data >> i) & 1); 
     digitalWrite(LCD_WR,HIGH);delayMicroseconds(10);
     } 
     delayMicroseconds(10);digitalWrite(LCD_CS,HIGH);
     delayMicroseconds(10);digitalWrite(LCD_WR,LOW);
     delayMicroseconds(10);
  }

void data_101(int addr, int data){
     digitalWrite(LCD_CS,LOW);
   for(int i = 2; i >=0; i--){
     digitalWrite(LCD_WR,LOW);delayMicroseconds(10);
     digitalWrite(LCD_DATA, (0b101 >> i) & 1); 
     digitalWrite(LCD_WR,HIGH);delayMicroseconds(10);
     } 
   for(int i = 5; i >=0; i--){
     digitalWrite(LCD_WR,LOW);delayMicroseconds(10);
     digitalWrite(LCD_DATA, (addr >> i) & 1); 
     digitalWrite(LCD_WR,HIGH);delayMicroseconds(10);
     } 
   for(int i = 0; i <=3; i++){
     digitalWrite(LCD_WR,LOW);delayMicroseconds(10);
     digitalWrite(LCD_DATA, (data >> i) & 1); 
     digitalWrite(LCD_WR,HIGH);delayMicroseconds(10);
     }   
     delayMicroseconds(10);digitalWrite(LCD_CS,HIGH);
     delayMicroseconds(10);digitalWrite(LCD_WR,LOW);
  }