101

Re: BD37534FV+LCD2004+энкодер+ИК пульт

Александр, Вы можете добавить что бы все входы работали? Я использую скетч из 4 поста, вроде он работает, косяков в управлении не замечал.

102

Re: BD37534FV+LCD2004+энкодер+ИК пульт

Дифференциальные входы тоже нужны?

103

Re: BD37534FV+LCD2004+энкодер+ИК пульт

Да, хотелось бы, что бы были, если Вас не затруднит, этот проц, готовится под домашку, просто есть магнитофон tascam с диф выходами.

104

Re: BD37534FV+LCD2004+энкодер+ИК пульт

Тестируйте. В железе не проверял. Активно 10 входов 4 из которых дифференциальные

http://forum.rcl-radio.ru/uploads/images/2023/03/8b4a6dd2da2790aa32ee69524a244e2e.png


http://forum.rcl-radio.ru/uploads/images/2023/03/0c2c061ad9a927dd55909fc908294c67.png

#define IR_1 0x2FDD02F // Кнопка вверх
#define IR_2 0x2FD32CD // Кнопка вниз
#define IR_3 0x2FD906F // Кнопка >
#define IR_4 0x2FDF20D // Кнопка <
#define IR_5 0x2FD708F // Кнопка IN
#define IR_6 0x2FD6A95 // Кнопка MENU
#define IR_7 0x2FD00FF // Кнопка MUTE
#define IR_8 0x2FDB24D // Кнопка STANDBY (POWER)

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>  // http://forum.rcl-radio.ru/misc.php?action=pan_download&item=45&download=1
#include <BD37534FV.h>          // https://github.com/liman324/BD37534FV/archive/master.zip
#include <Encoder.h>            // http://rcl-radio.ru/wp-content/uploads/2019/05/Encoder.zip
#include <EEPROM.h>
#include <MsTimer2.h>           // http://rcl-radio.ru/wp-content/uploads/2018/11/MsTimer2.zip
#include <boarddefs.h>
#include <IRremote.h>           // http://rcl-radio.ru/wp-content/uploads/2019/06/IRremote.zip
#include <DS3231.h>             //https://github.com/jarzebski/Arduino-DS3231/archive/master.zip
   BD37534FV bd; 
   DS3231 clock;RTCDateTime DateTime;
   LiquidCrystal_I2C lcd(0x27,20,4);  // Устанавливаем дисплей
   IRrecv irrecv(12); // указываем вывод модуля IR приемника
   Encoder myEnc(9, 8);// DT, CLK
   decode_results ir; 

   unsigned long time0,times_in,oldPosition  = -999,newPosition; 
   byte in,in_x,w,w1,w2[4],w3,z,z0,z1,q,i,n,www,gr1,gr2,mute,power;
   int menu,menu0,menu_1,menu_2,vol,bass,treb,mid,vol_d,bass_d,treb_d,mid_d;
   int temp0,gain0,gain1,gain2,gain3,gain4,gain5,gain6,gain7,gain8,gain9,gain10,gain_d;
   int bass_f,bass_q,treb_f,treb_q,mid_f,mid_q,loud_f,loud_g;
   int lf,rf,lr,rr,sub,sub_f,faza,par,hour,minut,secon;
   const PROGMEM byte mesto[8] ={4,13,4,13,4,13,4,13};
   const PROGMEM byte mesto1[8]={0,0,1,1,2,2,3,3};
   const PROGMEM byte mesto2[7]={0,11,0,11,11,0,11};
   const PROGMEM byte mesto3[7]={0,0,1,1,2,3,3};
   char * bass_nam[4] ={"60   Hz", "80   Hz", "100  Hz", "120  Hz"};
   char * treb_nam[4]= {"7.5 kHz", "10  kHz", "12.5kHz", "15  kHz"};
   char * mid_nam[4] ={"500  Hz", "1   kHz", "1.5 kHz", "2.5 kHz"};
   char * lon_nam[4] ={"250  Hz", "400  Hz", "800  Hz", "disable"};
   char * sub_nam[5] ={" OFF   ", " 55  Hz", " 85  Hz", " 120 Hz", " 160 Hz"};
  const PROGMEM float bass_nam_1[4]={0.5, 1.0, 1.5, 2.0};
  const PROGMEM float mid_nam_1[4]={0.75, 1.0, 1.25, 1.5};
  const PROGMEM float treb_nam_1[2]={0.75, 1.25};
  int inn;

void setup() {Serial.begin(9600);
  irrecv.enableIRIn();lcd.init();lcd.backlight();
  lcd.setCursor(0,1);lcd.print(" Sound Processor");lcd.setCursor(0,2);lcd.print(" BD37534FV"); delay(2000);
  pinMode(10,INPUT);  // МЕНЮ КНОПКА SW энкодера
  pinMode(2,INPUT);   // МЕНЮ НАСТРОЕК
  pinMode(3,INPUT);   // IN
  pinMode(4,INPUT);// КНОПКА MUTE
  pinMode(5,INPUT);// КНОПКА STANDBY
  pinMode(7,OUTPUT);//  STANDBY
  MsTimer2::set(3, to_Timer);MsTimer2::start();
  if(EEPROM.read(100)!=0){for(int i=0;i<101;i++){EEPROM.update(i,0);}}// очистка памяти при первом включении 
  vol = EEPROM.read(0)-79;treb = EEPROM.read(1)-20;mid = EEPROM.read(2)-20;bass = EEPROM.read(3)-20;
  inn = EEPROM.read(4);gain1 = EEPROM.read(5);gain2 = EEPROM.read(6);gain3 = EEPROM.read(7);
  bass_f = EEPROM.read(8);bass_q = EEPROM.read(9);treb_f = EEPROM.read(10);treb_q = EEPROM.read(11);
  mid_f = EEPROM.read(12);mid_q = EEPROM.read(13);loud_f = EEPROM.read(14);loud_g= EEPROM.read(15);
  lf = EEPROM.read(16)-79;rf = EEPROM.read(17)-79;lr = EEPROM.read(18)-79;rr = EEPROM.read(19)-79;sub = EEPROM.read(20)-79;sub_f = EEPROM.read(21);
  faza = EEPROM.read(22);
  gain4 = EEPROM.read(30);gain5 = EEPROM.read(31);gain6 = EEPROM.read(32);gain7 = EEPROM.read(33);gain8 = EEPROM.read(34);gain9 = EEPROM.read(35);gain10 = EEPROM.read(36);
  switch(inn){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     case 3: gain0 = gain4;break;
     case 4: gain0 = gain5;break;
     case 5: gain0 = gain6;break;
     case 6: gain0 = gain7;break;
     case 7: gain0 = gain8;break;
     case 8: gain0 = gain9;break;
     case 9: gain0 = gain10;break;
     }
  w2_arr();audio();cl();
  clock.begin();// Инициализируем работу с объектом библиотеки DS3231
  // УСТАНОВКА ВРЕМЕНИ
  // clock.setDateTime(2016, 9, 15, 0, 0, 0);// Установка времени вручную (Год, Месяц, День, Час, Минута, Секунда)
}

void loop(){
  DateTime = clock.getDateTime();hour = DateTime.hour;minut = DateTime.minute;secon = DateTime.second;
  if(mute==0){
  if(digitalRead(10)==LOW&&menu0==0){menu++;delay(200);time0=millis();w=1;w2_arr();if(menu>3){menu=0;}}// меню 0
  if(digitalRead(10)==LOW&&menu0==1){menu_1++;delay(200);time0=millis();w=1;if(menu_1>7){menu_1=0;}}// меню 1
  if(digitalRead(10)==LOW&&menu0==2){menu_2++;delay(200);time0=millis();w=1;if(menu_2>6){menu_2=0;}}// меню 2
 
  if(digitalRead(2)==HIGH){menu0++;cl();delay(200);time0=millis();w=1;w2_arr();menu=0;menu_1=0;menu_2=0;if(menu0>2){menu0=0;}}// меню
  if(digitalRead(3)==HIGH){inn++;cl();times_in=millis();in_x=1;w3=1;www=1;menu0=100;if(inn>9){inn=0;}
  switch(inn){
    case 0: in=0b00000;break;
    case 1: in=0b00001;break;
    case 2: in=0b00010;break;
    case 3: in=0b00011;break;
    case 4: in=0b01010;break;
    case 5: in=0b01011;break;
    case 6: in=0b01111;break;
    case 7: in=0b10000;break;
    case 8: in=0b00110;break;
    case 9: in=0b01001;break;
    }
  }// IN
  }
  if(digitalRead(4)==HIGH&&mute==0&&power==0){mute=1;cl();w=1;w2_arr();lcd.setCursor(8,1);lcd.print("MUTE");menu0=100;audio();}// mute on
  if(digitalRead(4)==HIGH&&mute==1&&power==0){mute=0;cl();time0=millis();w=1;w2_arr();menu0=0;myEnc.write(0);audio();}// mute off

  if(digitalRead(5)==HIGH&&power==0&&digitalRead(3)==LOW){power=1;mute=1;audio();lcd.clear();lcd.setCursor(5,1);lcd.print("POWER  OFF");menu0=100;delay(3000);lcd.noBacklight();}// power off
  if(digitalRead(5)==HIGH&&power==1&&digitalRead(3)==LOW){power=0;mute=0;audio();lcd.backlight();lcd.clear();lcd.setCursor(5,1);lcd.print("POWER   ON ");w=1;w2_arr();menu0=0;myEnc.write(0);audio();delay(3000);lcd.clear();}// power on
  if(power==0){digitalWrite(7,HIGH);
   byte a1[8] = {0b00000,0b10101,0b10101,0b10101,0b10101,0b10101,0b10101,0b00000};
   byte a2[8] = {0b00000,0b10100,0b10100,0b10100,0b10100,0b10100,0b10100,0b00000};
   byte a3[8] = {0b00000,0b10000,0b10000,0b10000,0b10000,0b10000,0b10000,0b00000}; 
   byte a4[8] = {0b10000,0b11000,0b11100,0b11110,0b11100,0b11000,0b10000,0b00000}; 
   lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3);lcd.createChar(3,a4);
  }
  if(power==1){digitalWrite(7,LOW);
      byte v1[8] = {7,7,7,7,7,7,7,7};
      byte v2[8] = {7,7,0, 0, 0, 0, 0, 0};      
      byte v3[8] = { 0, 0, 0, 0, 0,0,31,31};
      byte v4[8] = {31,31, 0, 0, 0, 0,31,31};
      byte v5[8] = { 28, 28, 0, 0, 0, 0, 28, 28};
      byte v6[8] = {28,28,28,28,28,28,28,28};
      byte v7[8] = { 0, 0, 0, 0, 0, 0,7,7};
      byte v8[8] = { 31, 31,0,0,0,0,0, 0};
   byte a[6];
   byte i0,d1,d2,d3,d4,d5,d6,e1,e2,e3;
  lcd.createChar(1, v1);lcd.createChar(2, v2);lcd.createChar(3, v3);lcd.createChar(4, v4);lcd.createChar(5, v5);lcd.createChar(6, v6);lcd.createChar(7, v7);lcd.createChar(8, v8);

     a[0]=DateTime.hour/10;
     a[1]=DateTime.hour%10;
     a[2]=DateTime.minute/10;
     a[3]=DateTime.minute%10;
     a[4]=DateTime.second/10;
     a[5]=DateTime.second%10;
    
 for(i=0;i<6;i++){
      switch(i){
        case 0: e1=0,e2=1,e3=2;break;
        case 1: e1=3,e2=4,e3=5;break;
        case 2: e1=7,e2=8,e3=9;break;
        case 3: e1=10,e2=11,e3=12;break;
        case 4: e1=14,e2=15,e3=16;break;
        case 5: e1=17,e2=18,e3=19;break;
        }
      switch(a[i]){
        case 0: d1=1,d2=8,d3=6,d4=1,d5=3,d6=6;break;
        case 1: d1=32,d2=2,d3=6,d4=32,d5=32,d6=6;break;
        case 2: d1=2,d2=8,d3=6,d4=1,d5=4,d6=5;break;
        case 3: d1=2,d2=4,d3=6,d4=7,d5=3,d6=6;break;
        case 4: d1=1,d2=3,d3=6,d4=32,d5=32,d6=6;break;
        case 5: d1=1,d2=4,d3=5,d4=7,d5=3,d6=6;break;
        case 6: d1=1,d2=4,d3=5,d4=1,d5=3,d6=6;break;
        case 7: d1=1,d2=8,d3=6,d4=32,d5=32,d6=6;break;
        case 8: d1=1,d2=4,d3=6,d4=1,d5=3,d6=6;break;
        case 9: d1=1,d2=4,d3=6,d4=7,d5=3,d6=6;break;
    }
     
      lcd.setCursor(e1,0);lcd.write((uint8_t)d1);lcd.setCursor(e2,0);lcd.write((uint8_t)d2);lcd.setCursor(e3,0);lcd.write((uint8_t)d3);
      lcd.setCursor(e1,1);lcd.write((uint8_t)d4);lcd.setCursor(e2,1);lcd.write((uint8_t)d5);lcd.setCursor(e3,1);lcd.write((uint8_t)d6);
  }
  lcd.setCursor(6,0);lcd.print(".");lcd.setCursor(13,0);lcd.print(".");lcd.setCursor(6,1);lcd.print(".");lcd.setCursor(13,1);lcd.print(".");
  lcd.setCursor(5,3);lcd.print("POWER  OFF");lcd.noBacklight();
  if(digitalRead(3)==HIGH&&digitalRead(2)==HIGH){hour++;if(hour>23){hour=0;} clock.setDateTime(2020, 9, 15, hour, minut, secon);delay(100);}
  if(digitalRead(3)==HIGH&&digitalRead(4)==HIGH){minut++;if(minut>59){minut=0;} clock.setDateTime(2020, 9, 15, hour, minut, secon);delay(100); }
  if(digitalRead(3)==HIGH&&digitalRead(5)==HIGH){secon=0; clock.setDateTime(2020, 9, 15, hour, minut, secon);delay(100); }
  } 

  ////////////////////// IR /////////////////////////////////////////////////
  if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);irrecv.resume();time0=millis();w=1;}// IR приемник - чтение, в мониторе порта отображаются коды кнопок
  if(ir.value==0){gr1=0;gr2=0;}// запрет нажатий не активных кнопок пульта
   if(mute==0){
   if(ir.value==IR_2&&menu0==0){menu++;gr1=0;gr2=0;cl1();time0=millis();w=1;if(menu>3){menu=0;}}//  кнопка вверх 
   if(ir.value==IR_1&&menu0==0){menu--;gr1=0;gr2=0;cl1();time0=millis();w=1;if(menu<0){menu=3;}}//  кнопка вниз
   if(ir.value==IR_2&&menu0==1){menu_1++;gr1=0;gr2=0;cl1();time0=millis();w=1;if(menu_1>7){menu_1=0;}}//  кнопка вверх 
   if(ir.value==IR_1&&menu0==1){menu_1--;gr1=0;gr2=0;cl1();time0=millis();w=1;if(menu_1<0){menu_1=7;}}//  кнопка вниз
   if(ir.value==IR_2&&menu0==2){menu_2++;gr1=0;gr2=0;cl1();time0=millis();w=1;if(menu_2>6){menu_2=0;}}//  кнопка вверх 
   if(ir.value==IR_1&&menu0==2){menu_2--;gr1=0;gr2=0;cl1();time0=millis();w=1;if(menu_2<0){menu_2=6;}}//  кнопка вниз
 
   if(ir.value==IR_6){menu0++;gr1=0;gr2=0;cl();time0=millis();w=1;w2_arr();menu=0;menu_1;menu_2;if(menu0>2){menu0=0;}}//  кнопка MENU
   if(ir.value==IR_5){in++;gr1=0;gr2=0;cl();times_in=millis();in_x=1;w3=1;www=1;menu0=100;if(in>2){in=0;}}//  кнопка IN
   }
   if(ir.value==IR_7&&mute==0&&power==0){mute=1;cl();w=1;w2_arr();lcd.setCursor(8,1);lcd.print("MUTE");menu0=100;audio();}// mute on
   if(ir.value==IR_7&&mute==1&&power==0){mute=0;cl();time0=millis();w=1;w2_arr();menu0=0;myEnc.write(0);audio();}// mute off

   if(ir.value==IR_8&&power==0){power=1;mute=1;audio();cl();lcd.setCursor(5,1);lcd.print("POWER  OFF");menu0=100;delay(3000);lcd.noBacklight();}// power off
   if(ir.value==IR_8&&power==1){power=0;mute=0;audio();lcd.backlight();cl();lcd.setCursor(5,1);lcd.print("POWER   ON ");w=1;w2_arr();menu0=0;myEnc.write(0);audio();delay(3000);lcd.clear();}// power on
   
   /////////////////////////////// MENU0 = VOLUME TERBLE MIDDLE BASS ///////////////////////////////////////////////////////////////////////
  if(menu0==0){
    switch(menu){
      case 0: temp0 = vol;q=0;break;
      case 1: temp0 = bass;q=1;break;
      case 2: temp0 = mid;q=2;break;
      case 3: temp0 = treb;q=3;break;}
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();;w=1;w2[q]=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();;w=1;w2[q]=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка <<<<<<   
 
   if (newPosition != oldPosition){oldPosition = newPosition;
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();w=1;w2[q]=1;www=1;} 
 
     switch(menu){
      case 0: vol = temp0;vol_func();break;
      case 1: bass = temp0;bass_func();break;
      case 2: mid = temp0;mid_func();break;
      case 3: treb = temp0;treb_func();break;}
 
   au();
   for(i=0;i<4;i++){if(menu==i){lcd.setCursor(0,i);lcd.write((uint8_t)3);}else{lcd.setCursor(0,i);lcd.print(" ");}}
   lcd.setCursor(1,0);lcd.print("VOLUME ");if(vol>=0){lcd.print(" ");}lcd.print(vol);lcd.print(" ");vol_d=map(vol,-79,15,0,24);
   lcd.setCursor(1,1);lcd.print("BASS   ");if(bass>=0){lcd.print(" ");}lcd.print(bass);lcd.print(" ");bass_d=map(bass,-20,20,0,24);
   lcd.setCursor(1,2);lcd.print("MIDDLE ");if(mid>=0){lcd.print(" ");}lcd.print(mid);lcd.print(" ");mid_d=map(mid,-20,20,0,24);
   lcd.setCursor(1,3);lcd.print("TREBLE ");if(treb>=0){lcd.print(" ");}lcd.print(treb);lcd.print(" ");treb_d=map(treb,-20,20,0,24);

   for(n=0;n<4;n++){if(w2[n]==1){
   switch(n){
    case 0: par = vol_d;break;
    case 1: par = bass_d;break;
    case 2: par = mid_d;break;
    case 3: par = treb_d;break;
    } 
   for(z=0,z0=0,z1=0;z<=par;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+12,n);lcd.write((uint8_t)0);lcd.setCursor(z0+1+12,n);lcd.print(" ");}}
   if(z1==3){lcd.setCursor(z0+12,n);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+12,n);lcd.write((uint8_t)2);}w2[n]=0;}
   }}// menu0 = 0
///////////////////////////////////////////////////////////////////////////////////////////////
  
  ///////////////////// MENU 2 ////////////////////////////////////////////////////////
 if(menu0==1){
  switch(menu_1){
      case 0: temp0 = bass_f;break;
      case 1: temp0 = bass_q;break;
      case 2: temp0 = mid_f;break;
      case 3: temp0 = mid_q;break;
      case 4: temp0 = treb_f;break;
      case 5: temp0 = treb_q;break;
      case 6: temp0 = loud_f;break;
      case 7: temp0 = loud_g;break;}
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();;w=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();w=1;www=1;}// кнопка <<<<<<     
 
   if (newPosition != oldPosition){oldPosition = newPosition;
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();w=1;www=1;} 
 
     switch(menu_1){
      case 0: bass_f = temp0;bass_f_func();break;
      case 1: bass_q = temp0;bass_q_func();break;
      case 2: mid_f = temp0;mid_f_func();break;
      case 3: mid_q = temp0;mid_q_func();break;
      case 4: treb_f = temp0;treb_f_func();break;
      case 5: treb_q = temp0;treb_q_func();break;
      case 6: loud_f = temp0;loud_f_func();break;
      case 7: loud_g = temp0;loud_g_func();break;}
 
  au();
  for(i=0;i<8;i++){if(menu_1==i){lcd.setCursor(pgm_read_byte(&mesto[i]),pgm_read_byte(&mesto1[i]));lcd.write((uint8_t)3);}else{lcd.setCursor(pgm_read_byte(&mesto[i]),pgm_read_byte(&mesto1[i]));lcd.print(" ");}}
  lcd.setCursor(0,0);lcd.print("BASS");lcd.setCursor(5,0);lcd.print(bass_nam[bass_f]);lcd.setCursor(14,0);lcd.print("Q ");lcd.print(pgm_read_float(&bass_nam_1[bass_q]));
  lcd.setCursor(0,1);lcd.print("MIDD");lcd.setCursor(5,1);lcd.print(mid_nam[mid_f]);lcd.setCursor(14,1);lcd.print("Q ");lcd.print(pgm_read_float(&mid_nam_1[mid_q]));
  lcd.setCursor(0,2);lcd.print("TREB");lcd.setCursor(5,2);lcd.print(treb_nam[treb_f]);lcd.setCursor(14,2);lcd.print("Q ");lcd.print(pgm_read_float(&treb_nam_1[treb_q]));
  lcd.setCursor(0,3);lcd.print("LOUD");lcd.setCursor(5,3);lcd.print(lon_nam[loud_f]);lcd.setCursor(14,3);lcd.print("G ");lcd.print(loud_g/10);lcd.print(loud_g%10);lcd.setCursor(18,3);lcd.print("dB");
  }// menu0 = 1
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

  if(menu0==2){
     switch(menu_2){
      case 0: temp0 = lf;break;
      case 1: temp0 = rf;break;
      case 2: temp0 = lr;break;
      case 3: temp0 = rr;break;
      case 4: temp0 = faza;break;
      case 5: temp0 = sub;break;
      case 6: temp0 = sub_f;break;}
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();;w=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();w=1;www=1;}// кнопка <<<<<<     
 
   if (newPosition != oldPosition){oldPosition = newPosition;
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();w=1;www=1;} 
 
     switch(menu_2){
      case 0: lf = temp0;lf_func();break;
      case 1: rf = temp0;rf_func();break;
      case 2: lr = temp0;lr_func();break;
      case 3: rr = temp0;rr_func();break;
      case 4: faza = temp0;faza_func();break;
      case 5: sub = temp0;sub_func();break;
      case 6: sub_f = temp0;sub_f_func();break;}
 
  au();
  for(i=0;i<7;i++){if(menu_2==i){lcd.setCursor(pgm_read_byte(&mesto2[i]),pgm_read_byte(&mesto3[i]));lcd.write((uint8_t)3);}else{lcd.setCursor(pgm_read_byte(&mesto2[i]),pgm_read_byte(&mesto3[i]));lcd.print(" ");}}
  lcd.setCursor(1,0);lcd.print("LF");lcd.setCursor(4,0);lcd.print(lf);lcd.print(" ");lcd.setCursor(7,0);lcd.print("dB ");lcd.setCursor(12,0);lcd.print("RF ");lcd.print(rf);lcd.print(" ");lcd.setCursor(18,0);lcd.print("dB");
  lcd.setCursor(1,1);lcd.print("LR");lcd.setCursor(4,1);lcd.print(lr);lcd.print(" ");lcd.setCursor(7,1);lcd.print("dB ");lcd.setCursor(12,1);lcd.print("RR ");lcd.print(rr);lcd.print(" ");lcd.setCursor(18,1);lcd.print("dB");
  lcd.setCursor(1,2);lcd.print("Subwoofer");lcd.setCursor(12,2);lcd.print("Faza ");if(faza==0){lcd.print("  0");}else{lcd.print("180");}
  lcd.setCursor(1,3);lcd.print("G ");lcd.setCursor(4,3);lcd.print(sub);lcd.print(" ");lcd.setCursor(7,3);lcd.print("dB ");lcd.setCursor(12,3);lcd.print(sub_nam[sub_f]);
 } // menu0 = 2


 ////////////////////////// GAIN IN /////////////////////////////////////////////////////////////////////////////////////
if(in_x==1){ menu0=100;
   switch(inn){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     case 3: gain0 = gain4;break;
     case 4: gain0 = gain5;break;
     case 5: gain0 = gain6;break;
     case 6: gain0 = gain7;break;
     case 7: gain0 = gain8;break;
     case 8: gain0 = gain9;break;
     case 9: gain0 = gain10;break;
     }
 
     if(ir.value==IR_3){gain0++;gr1=1;gr2=0;cl1();time0=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){gain0++;gr2=0;cl1();time0=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка >>>>>>
     if(ir.value==IR_4){gain0--;gr1=0;gr2=1;cl1();time0=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){gain0--;gr1=0;cl1();time0=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка <<<<<<  
 
    if (newPosition != oldPosition) {oldPosition = newPosition;
    gain0=gain0+newPosition;myEnc.write(0);newPosition=0;time0=millis();times_in=millis();www=1;w=1;w3=1;gain_func();} 
 
   switch(inn){
     case 0: gain1 = gain0;break;
     case 1: gain2 = gain0;break;
     case 2: gain3 = gain0;break;
     case 3: gain4 = gain0;break;
     case 4: gain5 = gain0;break;
     case 5: gain6 = gain0;break;
     case 6: gain7 = gain0;break;
     case 7: gain8 = gain0;break;
     case 8: gain9 = gain0;break;
     case 9: gain10 = gain0;break;
     
     }
 
  au();
  lcd.setCursor(2,1);lcd.print("Gain ");lcd.print(inn+1);
  switch(inn){
    case 0: lcd.print("IN_1   ");break;
    case 1: lcd.print("IN_1   ");break;
    case 2: lcd.print("IN_3   ");break;
    case 3: lcd.print("IN_4   ");break;
    case 4: lcd.print("IN_5   ");break;
    case 5: lcd.print("IN_6   ");break;
    case 6: lcd.print("IN_7_D ");break;
    case 7: lcd.print("IN_8_D ");break;
    case 8: lcd.print("IN_9_D ");break;
    case 9: lcd.print("IN_10_D");break;
    }
  lcd.setCursor(12,1);lcd.print(" ");lcd.print(gain0);lcd.print(" ");lcd.setCursor(16,1);lcd.print("dB");gain_d=gain0+1;
   if(w3==1){
   for(z=0,z0=0,z1=0;z<=gain_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+7,2);lcd.write((uint8_t)0);lcd.setCursor(z0+1+7,2);lcd.print("   ");}}
   if(z1==3){lcd.setCursor(z0+7,2);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+7,2);lcd.write((uint8_t)2);}} w3=0;
   if(millis()-times_in>3000){in_x=0;cl();menu0=0;w2_arr();}}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////   
 
  
  ///////////////////// EEPROM ///////////////////////////////////////////////////////////////         
  if(millis()-time0>10000 && w==1){
     EEPROM.update(0,vol+79);EEPROM.update(1,treb+20);EEPROM.update(2,mid+20);EEPROM.update(3,bass+20);
     EEPROM.update(4,in);EEPROM.update(5,gain1);EEPROM.update(6,gain2);EEPROM.update(7,gain3);
     EEPROM.update(8,bass_f);EEPROM.update(9,bass_q);EEPROM.update(10,treb_f);EEPROM.update(11,treb_q),
     EEPROM.update(12,mid_f);EEPROM.update(13,mid_q);EEPROM.update(14,loud_f);EEPROM.update(15,loud_g);
     EEPROM.update(16,lf+79);EEPROM.update(17,rf+79);EEPROM.update(18,lr+79);EEPROM.update(19,rr+79);EEPROM.update(20,sub+79);EEPROM.update(21,sub_f);
     EEPROM.update(22,faza);
     EEPROM.update(30,gain4);EEPROM.update(31,gain5);EEPROM.update(32,gain6);EEPROM.update(33,gain7);EEPROM.update(34,gain8);EEPROM.update(35,gain9);EEPROM.update(36,gain10);
     menu=0;menu_1=0;menu_2=0;w=0;w2_arr();}
  
  }// loop

void faza_func(){if(faza>1){faza=0;}if(faza<0){faza=1;}}   
void sub_f_func(){if(sub_f>4){sub_f=0;}if(sub_f<0){sub_f=4;}}
void lf_func(){if(lf<-79){lf=-79;}if(lf>15){lf=15;}};
void rf_func(){if(rf<-79){rf=-79;}if(rf>15){rf=15;}};
void lr_func(){if(lr<-79){lr=-79;}if(lr>15){lr=15;}};
void rr_func(){if(rr<-79){rr=-79;}if(rr>15){rr=15;}};
void sub_func(){if(sub<-79){sub=-79;}if(sub>15){sub=15;}};
void au(){if(www==1){audio();www=0;}}
void loud_f_func(){if(loud_f>3){loud_f=0;}if(loud_f<0){loud_f=3;}}
void loud_g_func(){if(loud_g>20){loud_g=20;}if(loud_g<0){loud_g=0;}}
void mid_q_func(){if(mid_q>3){mid_q=0;}if(mid_q<0){mid_q=3;}}
void treb_q_func(){if(treb_q>1){treb_q=0;}if(treb_q<0){treb_q=1;}}
void bass_q_func(){if(bass_q>3){bass_q=0;}if(bass_q<0){bass_q=3;}}
void mid_f_func(){if(mid_f>3){mid_f=0;}if(mid_f<0){mid_f=3;}}
void treb_f_func(){if(treb_f>3){treb_f=0;}if(treb_f<0){treb_f=3;}}
void bass_f_func(){if(bass_f>3){bass_f=0;}if(bass_f<0){bass_f=3;}}
void gain_func(){if(gain0<0){gain0=0;}if(gain0>20){gain0=20;}}
void bass_func(){if(bass>20){bass=20;}if(bass<-20){bass=-20;}} 
void mid_func(){if(mid>20){mid=20;}if(mid<-20){mid=-20;}}
void treb_func(){if(treb>20){treb=20;}if(treb<-20){treb=-20;}}
void vol_func(){if(vol<-79){vol=-79;}if(vol>15){vol=15;}}
void w2_arr(){w2[0]=1;w2[1]=1;w2[2]=1;w2[3]=1;}
void cl(){ir.value=0;delay(300);lcd.clear();}
void cl1(){ir.value=0;delay(200);}  


void audio(){
   bd.setSetup_1(1,2,0); // default (1,2,0)
   bd.setSetup_2(sub_f,1,0,faza); 
                   // int sub_f ------ OFF 55Hz 85Hz 120Hz 160Hz = int 0...4
                   // int sub_out ---- LPF Front Rear Prohibition = int 0...3
                   // int level_metr - HOLD REST = int 0..1
                   // int faza ------- 0 180 = int 0...1
   bd.setLoudness_f(loud_f); // 250Hz 400Hz 800Hz Prohibition = int 0...3
   bd.setIn(in); // 0...2
   bd.setIn_gain(gain0,mute); // in_gain -- 0...20 = 0...20 dB, mute -- 0 default 
   bd.setVol(vol); // -79...+15 dB = int -79...15
   bd.setFront_1(rf); // -79...+15 dB = int -79...15
   bd.setFront_2(lf); // -79...+15 dB = int -79...15
   bd.setRear_1(rr); // -79...+15 dB = int -79...15
   bd.setRear_2(lr); // -79...+15 dB = int -79...15
   bd.setSub(sub); // -79...+15 dB = int -79...15
   bd.mix();
   bd.setBass_setup(bass_q,bass_f); // 0.5 1.0 1.5 2.0 --- int 0...3, 60Hz 80Hz 100Hz 120Hz --- int 0...3
   bd.setMiddle_setup(mid_q,mid_f); // 0.75 1.0 1.25 1.5 --- int 0...3, 500Hz 1kHz 1.5kHz 2.5kHz --- int 0...3
   bd.setTreble_setup(treb_q,treb_f); // 0.75 1.25  --- int 0...1, 7.5kHz 10kHz 12.5kHz 15kHz --- int 0...3
   bd.setBass_gain(bass); // --20 ... +20 dB = int -20 ... 20  
   bd.setMiddle_gain(mid); // --20 ... +20 dB = int -20 ... 20
   bd.setTreble_gain(treb); // --20 ... +20 dB = int -20 ... 20   
   bd.setLoudness_gain(loud_g); // 0 ... 20 dB = int 0 ... 20
  }  

void to_Timer(){newPosition = myEnc.read()/4;}  

105

Re: BD37534FV+LCD2004+энкодер+ИК пульт

Благодарю, будем тестить.

106 (2023-03-08 09:17:01 отредактировано peregar78)

Re: BD37534FV+LCD2004+энкодер+ИК пульт

Александр, не переключает каналы совсем, но gain 1 по умолчанию регулирует усиление от (0 до 20),кнопка переключения каналов при нажатии включает канал номер 1.

107

Re: BD37534FV+LCD2004+энкодер+ИК пульт

Названия каналов меняются?

108 (2023-03-08 10:34:10 отредактировано peregar78)

Re: BD37534FV+LCD2004+энкодер+ИК пульт

нет не меняется, при нажатии включается  gain 1 и на этом все, схема собрана и подключена прямо сейчас на столе

109

Re: BD37534FV+LCD2004+энкодер+ИК пульт

пока снова залил с 4 поста,все работает

110

Re: BD37534FV+LCD2004+энкодер+ИК пульт

Попробуйте этот код

#define IR_1 0x2FDD02F // Кнопка вверх
#define IR_2 0x2FD32CD // Кнопка вниз
#define IR_3 0x2FD906F // Кнопка >
#define IR_4 0x2FDF20D // Кнопка <
#define IR_5 0x2FD708F // Кнопка IN
#define IR_6 0x2FD6A95 // Кнопка MENU
#define IR_7 0x2FD00FF // Кнопка MUTE
#define IR_8 0x2FDB24D // Кнопка STANDBY (POWER)

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>  // http://forum.rcl-radio.ru/misc.php?action=pan_download&item=45&download=1
#include <BD37534FV.h>          // https://github.com/liman324/BD37534FV/archive/master.zip
#include <Encoder.h>            // http://rcl-radio.ru/wp-content/uploads/2019/05/Encoder.zip
#include <EEPROM.h>
#include <MsTimer2.h>           // http://rcl-radio.ru/wp-content/uploads/2018/11/MsTimer2.zip
#include <boarddefs.h>
#include <IRremote.h>           // http://rcl-radio.ru/wp-content/uploads/2019/06/IRremote.zip
#include <DS3231.h>             //https://github.com/jarzebski/Arduino-DS3231/archive/master.zip
   BD37534FV bd; 
   DS3231 clock;RTCDateTime DateTime;
   LiquidCrystal_I2C lcd(0x27,20,4);  // Устанавливаем дисплей
   IRrecv irrecv(12); // указываем вывод модуля IR приемника
   Encoder myEnc(9, 8);// DT, CLK
   decode_results ir; 

   unsigned long time0,times_in,oldPosition  = -999,newPosition; 
   byte in,in_x,w,w1,w2[4],w3,z,z0,z1,q,i,n,www,gr1,gr2,mute,power;
   int menu,menu0,menu_1,menu_2,vol,bass,treb,mid,vol_d,bass_d,treb_d,mid_d;
   int temp0,gain0,gain1,gain2,gain3,gain4,gain5,gain6,gain7,gain8,gain9,gain10,gain_d;
   int bass_f,bass_q,treb_f,treb_q,mid_f,mid_q,loud_f,loud_g;
   int lf,rf,lr,rr,sub,sub_f,faza,par,hour,minut,secon;
   const PROGMEM byte mesto[8] ={4,13,4,13,4,13,4,13};
   const PROGMEM byte mesto1[8]={0,0,1,1,2,2,3,3};
   const PROGMEM byte mesto2[7]={0,11,0,11,11,0,11};
   const PROGMEM byte mesto3[7]={0,0,1,1,2,3,3};
   char * bass_nam[4] ={"60   Hz", "80   Hz", "100  Hz", "120  Hz"};
   char * treb_nam[4]= {"7.5 kHz", "10  kHz", "12.5kHz", "15  kHz"};
   char * mid_nam[4] ={"500  Hz", "1   kHz", "1.5 kHz", "2.5 kHz"};
   char * lon_nam[4] ={"250  Hz", "400  Hz", "800  Hz", "disable"};
   char * sub_nam[5] ={" OFF   ", " 55  Hz", " 85  Hz", " 120 Hz", " 160 Hz"};
  const PROGMEM float bass_nam_1[4]={0.5, 1.0, 1.5, 2.0};
  const PROGMEM float mid_nam_1[4]={0.75, 1.0, 1.25, 1.5};
  const PROGMEM float treb_nam_1[2]={0.75, 1.25};
  int inn;

void setup() {Serial.begin(9600);
  irrecv.enableIRIn();lcd.init();lcd.backlight();
  lcd.setCursor(0,1);lcd.print(" Sound Processor");lcd.setCursor(0,2);lcd.print(" BD37534FV"); delay(2000);
  pinMode(10,INPUT);  // МЕНЮ КНОПКА SW энкодера
  pinMode(2,INPUT);   // МЕНЮ НАСТРОЕК
  pinMode(3,INPUT);   // IN
  pinMode(4,INPUT);// КНОПКА MUTE
  pinMode(5,INPUT);// КНОПКА STANDBY
  pinMode(7,OUTPUT);//  STANDBY
  MsTimer2::set(3, to_Timer);MsTimer2::start();
  if(EEPROM.read(100)!=0){for(int i=0;i<101;i++){EEPROM.update(i,0);}}// очистка памяти при первом включении 
  vol = EEPROM.read(0)-79;treb = EEPROM.read(1)-20;mid = EEPROM.read(2)-20;bass = EEPROM.read(3)-20;
  inn = EEPROM.read(4);gain1 = EEPROM.read(5);gain2 = EEPROM.read(6);gain3 = EEPROM.read(7);
  bass_f = EEPROM.read(8);bass_q = EEPROM.read(9);treb_f = EEPROM.read(10);treb_q = EEPROM.read(11);
  mid_f = EEPROM.read(12);mid_q = EEPROM.read(13);loud_f = EEPROM.read(14);loud_g= EEPROM.read(15);
  lf = EEPROM.read(16)-79;rf = EEPROM.read(17)-79;lr = EEPROM.read(18)-79;rr = EEPROM.read(19)-79;sub = EEPROM.read(20)-79;sub_f = EEPROM.read(21);
  faza = EEPROM.read(22);
  gain4 = EEPROM.read(30);gain5 = EEPROM.read(31);gain6 = EEPROM.read(32);gain7 = EEPROM.read(33);gain8 = EEPROM.read(34);gain9 = EEPROM.read(35);gain10 = EEPROM.read(36);
  switch(inn){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     case 3: gain0 = gain4;break;
     case 4: gain0 = gain5;break;
     case 5: gain0 = gain6;break;
     case 6: gain0 = gain7;break;
     case 7: gain0 = gain8;break;
     case 8: gain0 = gain9;break;
     case 9: gain0 = gain10;break;
     }
  w2_arr();audio();cl();
  clock.begin();// Инициализируем работу с объектом библиотеки DS3231
  // УСТАНОВКА ВРЕМЕНИ
  // clock.setDateTime(2016, 9, 15, 0, 0, 0);// Установка времени вручную (Год, Месяц, День, Час, Минута, Секунда)
}

void loop(){
  DateTime = clock.getDateTime();hour = DateTime.hour;minut = DateTime.minute;secon = DateTime.second;
  if(mute==0){
  if(digitalRead(10)==LOW&&menu0==0){menu++;delay(200);time0=millis();w=1;w2_arr();if(menu>3){menu=0;}}// меню 0
  if(digitalRead(10)==LOW&&menu0==1){menu_1++;delay(200);time0=millis();w=1;if(menu_1>7){menu_1=0;}}// меню 1
  if(digitalRead(10)==LOW&&menu0==2){menu_2++;delay(200);time0=millis();w=1;if(menu_2>6){menu_2=0;}}// меню 2
 
  if(digitalRead(2)==HIGH){menu0++;cl();delay(200);time0=millis();w=1;w2_arr();menu=0;menu_1=0;menu_2=0;if(menu0>2){menu0=0;}}// меню
  if(digitalRead(3)==HIGH || ir.value==IR_5){inn++;gr1=0;gr2=0;cl();times_in=millis();in_x=1;w3=1;www=1;menu0=100;if(inn>9){inn=0;}
  switch(inn){
    case 0: in=0b00000;au();break;
    case 1: in=0b00001;au();break;
    case 2: in=0b00010;au();break;
    case 3: in=0b00011;au();break;
    case 4: in=0b01010;au();break;
    case 5: in=0b01011;au();break;
    case 6: in=0b01111;au();break;
    case 7: in=0b10000;au();break;
    case 8: in=0b00110;au();break;
    case 9: in=0b01001;au();break;
    }
  }// IN
  }
  if(digitalRead(4)==HIGH&&mute==0&&power==0){mute=1;cl();w=1;w2_arr();lcd.setCursor(8,1);lcd.print("MUTE");menu0=100;audio();}// mute on
  if(digitalRead(4)==HIGH&&mute==1&&power==0){mute=0;cl();time0=millis();w=1;w2_arr();menu0=0;myEnc.write(0);audio();}// mute off

  if(digitalRead(5)==HIGH&&power==0&&digitalRead(3)==LOW){power=1;mute=1;audio();lcd.clear();lcd.setCursor(5,1);lcd.print("POWER  OFF");menu0=100;delay(3000);lcd.noBacklight();}// power off
  if(digitalRead(5)==HIGH&&power==1&&digitalRead(3)==LOW){power=0;mute=0;audio();lcd.backlight();lcd.clear();lcd.setCursor(5,1);lcd.print("POWER   ON ");w=1;w2_arr();menu0=0;myEnc.write(0);audio();delay(3000);lcd.clear();}// power on
  if(power==0){digitalWrite(7,HIGH);
   byte a1[8] = {0b00000,0b10101,0b10101,0b10101,0b10101,0b10101,0b10101,0b00000};
   byte a2[8] = {0b00000,0b10100,0b10100,0b10100,0b10100,0b10100,0b10100,0b00000};
   byte a3[8] = {0b00000,0b10000,0b10000,0b10000,0b10000,0b10000,0b10000,0b00000}; 
   byte a4[8] = {0b10000,0b11000,0b11100,0b11110,0b11100,0b11000,0b10000,0b00000}; 
   lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3);lcd.createChar(3,a4);
  }
  if(power==1){digitalWrite(7,LOW);
      byte v1[8] = {7,7,7,7,7,7,7,7};
      byte v2[8] = {7,7,0, 0, 0, 0, 0, 0};      
      byte v3[8] = { 0, 0, 0, 0, 0,0,31,31};
      byte v4[8] = {31,31, 0, 0, 0, 0,31,31};
      byte v5[8] = { 28, 28, 0, 0, 0, 0, 28, 28};
      byte v6[8] = {28,28,28,28,28,28,28,28};
      byte v7[8] = { 0, 0, 0, 0, 0, 0,7,7};
      byte v8[8] = { 31, 31,0,0,0,0,0, 0};
   byte a[6];
   byte i0,d1,d2,d3,d4,d5,d6,e1,e2,e3;
  lcd.createChar(1, v1);lcd.createChar(2, v2);lcd.createChar(3, v3);lcd.createChar(4, v4);lcd.createChar(5, v5);lcd.createChar(6, v6);lcd.createChar(7, v7);lcd.createChar(8, v8);

     a[0]=DateTime.hour/10;
     a[1]=DateTime.hour%10;
     a[2]=DateTime.minute/10;
     a[3]=DateTime.minute%10;
     a[4]=DateTime.second/10;
     a[5]=DateTime.second%10;
    
 for(i=0;i<6;i++){
      switch(i){
        case 0: e1=0,e2=1,e3=2;break;
        case 1: e1=3,e2=4,e3=5;break;
        case 2: e1=7,e2=8,e3=9;break;
        case 3: e1=10,e2=11,e3=12;break;
        case 4: e1=14,e2=15,e3=16;break;
        case 5: e1=17,e2=18,e3=19;break;
        }
      switch(a[i]){
        case 0: d1=1,d2=8,d3=6,d4=1,d5=3,d6=6;break;
        case 1: d1=32,d2=2,d3=6,d4=32,d5=32,d6=6;break;
        case 2: d1=2,d2=8,d3=6,d4=1,d5=4,d6=5;break;
        case 3: d1=2,d2=4,d3=6,d4=7,d5=3,d6=6;break;
        case 4: d1=1,d2=3,d3=6,d4=32,d5=32,d6=6;break;
        case 5: d1=1,d2=4,d3=5,d4=7,d5=3,d6=6;break;
        case 6: d1=1,d2=4,d3=5,d4=1,d5=3,d6=6;break;
        case 7: d1=1,d2=8,d3=6,d4=32,d5=32,d6=6;break;
        case 8: d1=1,d2=4,d3=6,d4=1,d5=3,d6=6;break;
        case 9: d1=1,d2=4,d3=6,d4=7,d5=3,d6=6;break;
    }
     
      lcd.setCursor(e1,0);lcd.write((uint8_t)d1);lcd.setCursor(e2,0);lcd.write((uint8_t)d2);lcd.setCursor(e3,0);lcd.write((uint8_t)d3);
      lcd.setCursor(e1,1);lcd.write((uint8_t)d4);lcd.setCursor(e2,1);lcd.write((uint8_t)d5);lcd.setCursor(e3,1);lcd.write((uint8_t)d6);
  }
  lcd.setCursor(6,0);lcd.print(".");lcd.setCursor(13,0);lcd.print(".");lcd.setCursor(6,1);lcd.print(".");lcd.setCursor(13,1);lcd.print(".");
  lcd.setCursor(5,3);lcd.print("POWER  OFF");lcd.noBacklight();
  if(digitalRead(3)==HIGH&&digitalRead(2)==HIGH){hour++;if(hour>23){hour=0;} clock.setDateTime(2020, 9, 15, hour, minut, secon);delay(100);}
  if(digitalRead(3)==HIGH&&digitalRead(4)==HIGH){minut++;if(minut>59){minut=0;} clock.setDateTime(2020, 9, 15, hour, minut, secon);delay(100); }
  if(digitalRead(3)==HIGH&&digitalRead(5)==HIGH){secon=0; clock.setDateTime(2020, 9, 15, hour, minut, secon);delay(100); }
  } 

  ////////////////////// IR /////////////////////////////////////////////////
  if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);irrecv.resume();time0=millis();w=1;}// IR приемник - чтение, в мониторе порта отображаются коды кнопок
  if(ir.value==0){gr1=0;gr2=0;}// запрет нажатий не активных кнопок пульта
   if(mute==0){
   if(ir.value==IR_2&&menu0==0){menu++;gr1=0;gr2=0;cl1();time0=millis();w=1;if(menu>3){menu=0;}}//  кнопка вверх 
   if(ir.value==IR_1&&menu0==0){menu--;gr1=0;gr2=0;cl1();time0=millis();w=1;if(menu<0){menu=3;}}//  кнопка вниз
   if(ir.value==IR_2&&menu0==1){menu_1++;gr1=0;gr2=0;cl1();time0=millis();w=1;if(menu_1>7){menu_1=0;}}//  кнопка вверх 
   if(ir.value==IR_1&&menu0==1){menu_1--;gr1=0;gr2=0;cl1();time0=millis();w=1;if(menu_1<0){menu_1=7;}}//  кнопка вниз
   if(ir.value==IR_2&&menu0==2){menu_2++;gr1=0;gr2=0;cl1();time0=millis();w=1;if(menu_2>6){menu_2=0;}}//  кнопка вверх 
   if(ir.value==IR_1&&menu0==2){menu_2--;gr1=0;gr2=0;cl1();time0=millis();w=1;if(menu_2<0){menu_2=6;}}//  кнопка вниз
 
   if(ir.value==IR_6){menu0++;gr1=0;gr2=0;cl();time0=millis();w=1;w2_arr();menu=0;menu_1;menu_2;if(menu0>2){menu0=0;}}//  кнопка MENU
   }
   if(ir.value==IR_7&&mute==0&&power==0){mute=1;cl();w=1;w2_arr();lcd.setCursor(8,1);lcd.print("MUTE");menu0=100;audio();}// mute on
   if(ir.value==IR_7&&mute==1&&power==0){mute=0;cl();time0=millis();w=1;w2_arr();menu0=0;myEnc.write(0);audio();}// mute off

   if(ir.value==IR_8&&power==0){power=1;mute=1;audio();cl();lcd.setCursor(5,1);lcd.print("POWER  OFF");menu0=100;delay(3000);lcd.noBacklight();}// power off
   if(ir.value==IR_8&&power==1){power=0;mute=0;audio();lcd.backlight();cl();lcd.setCursor(5,1);lcd.print("POWER   ON ");w=1;w2_arr();menu0=0;myEnc.write(0);audio();delay(3000);lcd.clear();}// power on
   
   /////////////////////////////// MENU0 = VOLUME TERBLE MIDDLE BASS ///////////////////////////////////////////////////////////////////////
  if(menu0==0){
    switch(menu){
      case 0: temp0 = vol;q=0;break;
      case 1: temp0 = bass;q=1;break;
      case 2: temp0 = mid;q=2;break;
      case 3: temp0 = treb;q=3;break;}
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();;w=1;w2[q]=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();;w=1;w2[q]=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();w=1;w2[q]=1;www=1;}// кнопка <<<<<<   
 
   if (newPosition != oldPosition){oldPosition = newPosition;
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();w=1;w2[q]=1;www=1;} 
 
     switch(menu){
      case 0: vol = temp0;vol_func();break;
      case 1: bass = temp0;bass_func();break;
      case 2: mid = temp0;mid_func();break;
      case 3: treb = temp0;treb_func();break;}
 
   au();
   for(i=0;i<4;i++){if(menu==i){lcd.setCursor(0,i);lcd.write((uint8_t)3);}else{lcd.setCursor(0,i);lcd.print(" ");}}
   lcd.setCursor(1,0);lcd.print("VOLUME ");if(vol>=0){lcd.print(" ");}lcd.print(vol);lcd.print(" ");vol_d=map(vol,-79,15,0,24);
   lcd.setCursor(1,1);lcd.print("BASS   ");if(bass>=0){lcd.print(" ");}lcd.print(bass);lcd.print(" ");bass_d=map(bass,-20,20,0,24);
   lcd.setCursor(1,2);lcd.print("MIDDLE ");if(mid>=0){lcd.print(" ");}lcd.print(mid);lcd.print(" ");mid_d=map(mid,-20,20,0,24);
   lcd.setCursor(1,3);lcd.print("TREBLE ");if(treb>=0){lcd.print(" ");}lcd.print(treb);lcd.print(" ");treb_d=map(treb,-20,20,0,24);

   for(n=0;n<4;n++){if(w2[n]==1){
   switch(n){
    case 0: par = vol_d;break;
    case 1: par = bass_d;break;
    case 2: par = mid_d;break;
    case 3: par = treb_d;break;
    } 
   for(z=0,z0=0,z1=0;z<=par;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+12,n);lcd.write((uint8_t)0);lcd.setCursor(z0+1+12,n);lcd.print(" ");}}
   if(z1==3){lcd.setCursor(z0+12,n);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+12,n);lcd.write((uint8_t)2);}w2[n]=0;}
   }}// menu0 = 0
///////////////////////////////////////////////////////////////////////////////////////////////
  
  ///////////////////// MENU 2 ////////////////////////////////////////////////////////
 if(menu0==1){
  switch(menu_1){
      case 0: temp0 = bass_f;break;
      case 1: temp0 = bass_q;break;
      case 2: temp0 = mid_f;break;
      case 3: temp0 = mid_q;break;
      case 4: temp0 = treb_f;break;
      case 5: temp0 = treb_q;break;
      case 6: temp0 = loud_f;break;
      case 7: temp0 = loud_g;break;}
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();;w=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();w=1;www=1;}// кнопка <<<<<<     
 
   if (newPosition != oldPosition){oldPosition = newPosition;
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();w=1;www=1;} 
 
     switch(menu_1){
      case 0: bass_f = temp0;bass_f_func();break;
      case 1: bass_q = temp0;bass_q_func();break;
      case 2: mid_f = temp0;mid_f_func();break;
      case 3: mid_q = temp0;mid_q_func();break;
      case 4: treb_f = temp0;treb_f_func();break;
      case 5: treb_q = temp0;treb_q_func();break;
      case 6: loud_f = temp0;loud_f_func();break;
      case 7: loud_g = temp0;loud_g_func();break;}
 
  au();
  for(i=0;i<8;i++){if(menu_1==i){lcd.setCursor(pgm_read_byte(&mesto[i]),pgm_read_byte(&mesto1[i]));lcd.write((uint8_t)3);}else{lcd.setCursor(pgm_read_byte(&mesto[i]),pgm_read_byte(&mesto1[i]));lcd.print(" ");}}
  lcd.setCursor(0,0);lcd.print("BASS");lcd.setCursor(5,0);lcd.print(bass_nam[bass_f]);lcd.setCursor(14,0);lcd.print("Q ");lcd.print(pgm_read_float(&bass_nam_1[bass_q]));
  lcd.setCursor(0,1);lcd.print("MIDD");lcd.setCursor(5,1);lcd.print(mid_nam[mid_f]);lcd.setCursor(14,1);lcd.print("Q ");lcd.print(pgm_read_float(&mid_nam_1[mid_q]));
  lcd.setCursor(0,2);lcd.print("TREB");lcd.setCursor(5,2);lcd.print(treb_nam[treb_f]);lcd.setCursor(14,2);lcd.print("Q ");lcd.print(pgm_read_float(&treb_nam_1[treb_q]));
  lcd.setCursor(0,3);lcd.print("LOUD");lcd.setCursor(5,3);lcd.print(lon_nam[loud_f]);lcd.setCursor(14,3);lcd.print("G ");lcd.print(loud_g/10);lcd.print(loud_g%10);lcd.setCursor(18,3);lcd.print("dB");
  }// menu0 = 1
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

  if(menu0==2){
     switch(menu_2){
      case 0: temp0 = lf;break;
      case 1: temp0 = rf;break;
      case 2: temp0 = lr;break;
      case 3: temp0 = rr;break;
      case 4: temp0 = faza;break;
      case 5: temp0 = sub;break;
      case 6: temp0 = sub_f;break;}
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time0=millis();w=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time0=millis();;w=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time0=millis();w=1;www=1;}// кнопка <<<<<<     
 
   if (newPosition != oldPosition){oldPosition = newPosition;
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time0=millis();w=1;www=1;} 
 
     switch(menu_2){
      case 0: lf = temp0;lf_func();break;
      case 1: rf = temp0;rf_func();break;
      case 2: lr = temp0;lr_func();break;
      case 3: rr = temp0;rr_func();break;
      case 4: faza = temp0;faza_func();break;
      case 5: sub = temp0;sub_func();break;
      case 6: sub_f = temp0;sub_f_func();break;}
 
  au();
  for(i=0;i<7;i++){if(menu_2==i){lcd.setCursor(pgm_read_byte(&mesto2[i]),pgm_read_byte(&mesto3[i]));lcd.write((uint8_t)3);}else{lcd.setCursor(pgm_read_byte(&mesto2[i]),pgm_read_byte(&mesto3[i]));lcd.print(" ");}}
  lcd.setCursor(1,0);lcd.print("LF");lcd.setCursor(4,0);lcd.print(lf);lcd.print(" ");lcd.setCursor(7,0);lcd.print("dB ");lcd.setCursor(12,0);lcd.print("RF ");lcd.print(rf);lcd.print(" ");lcd.setCursor(18,0);lcd.print("dB");
  lcd.setCursor(1,1);lcd.print("LR");lcd.setCursor(4,1);lcd.print(lr);lcd.print(" ");lcd.setCursor(7,1);lcd.print("dB ");lcd.setCursor(12,1);lcd.print("RR ");lcd.print(rr);lcd.print(" ");lcd.setCursor(18,1);lcd.print("dB");
  lcd.setCursor(1,2);lcd.print("Subwoofer");lcd.setCursor(12,2);lcd.print("Faza ");if(faza==0){lcd.print("  0");}else{lcd.print("180");}
  lcd.setCursor(1,3);lcd.print("G ");lcd.setCursor(4,3);lcd.print(sub);lcd.print(" ");lcd.setCursor(7,3);lcd.print("dB ");lcd.setCursor(12,3);lcd.print(sub_nam[sub_f]);
 } // menu0 = 2


 ////////////////////////// GAIN IN /////////////////////////////////////////////////////////////////////////////////////
if(in_x==1){ menu0=100;
   switch(inn){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;
     case 3: gain0 = gain4;break;
     case 4: gain0 = gain5;break;
     case 5: gain0 = gain6;break;
     case 6: gain0 = gain7;break;
     case 7: gain0 = gain8;break;
     case 8: gain0 = gain9;break;
     case 9: gain0 = gain10;break;
     }
 
     if(ir.value==IR_3){gain0++;gr1=1;gr2=0;cl1();time0=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){gain0++;gr2=0;cl1();time0=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка >>>>>>
     if(ir.value==IR_4){gain0--;gr1=0;gr2=1;cl1();time0=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){gain0--;gr1=0;cl1();time0=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка <<<<<<  
 
    if (newPosition != oldPosition) {oldPosition = newPosition;
    gain0=gain0+newPosition;myEnc.write(0);newPosition=0;time0=millis();times_in=millis();www=1;w=1;w3=1;gain_func();} 
 
   switch(inn){
     case 0: gain1 = gain0;break;
     case 1: gain2 = gain0;break;
     case 2: gain3 = gain0;break;
     case 3: gain4 = gain0;break;
     case 4: gain5 = gain0;break;
     case 5: gain6 = gain0;break;
     case 6: gain7 = gain0;break;
     case 7: gain8 = gain0;break;
     case 8: gain9 = gain0;break;
     case 9: gain10 = gain0;break;
     
     }
 
  au();
  lcd.setCursor(2,1);lcd.print("Gain ");lcd.print(inn+1);
  switch(inn){
    case 0: lcd.print("IN_1   ");break;
    case 1: lcd.print("IN_1   ");break;
    case 2: lcd.print("IN_3   ");break;
    case 3: lcd.print("IN_4   ");break;
    case 4: lcd.print("IN_5   ");break;
    case 5: lcd.print("IN_6   ");break;
    case 6: lcd.print("IN_7_D ");break;
    case 7: lcd.print("IN_8_D ");break;
    case 8: lcd.print("IN_9_D ");break;
    case 9: lcd.print("IN_10_D");break;
    }
  lcd.setCursor(12,1);lcd.print(" ");lcd.print(gain0);lcd.print(" ");lcd.setCursor(16,1);lcd.print("dB");gain_d=gain0+1;
   if(w3==1){
   for(z=0,z0=0,z1=0;z<=gain_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+7,2);lcd.write((uint8_t)0);lcd.setCursor(z0+1+7,2);lcd.print("   ");}}
   if(z1==3){lcd.setCursor(z0+7,2);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+7,2);lcd.write((uint8_t)2);}} w3=0;
   if(millis()-times_in>3000){in_x=0;cl();menu0=0;w2_arr();}}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////   
 
  
  ///////////////////// EEPROM ///////////////////////////////////////////////////////////////         
  if(millis()-time0>10000 && w==1){
     EEPROM.update(0,vol+79);EEPROM.update(1,treb+20);EEPROM.update(2,mid+20);EEPROM.update(3,bass+20);
     EEPROM.update(4,inn);EEPROM.update(5,gain1);EEPROM.update(6,gain2);EEPROM.update(7,gain3);
     EEPROM.update(8,bass_f);EEPROM.update(9,bass_q);EEPROM.update(10,treb_f);EEPROM.update(11,treb_q),
     EEPROM.update(12,mid_f);EEPROM.update(13,mid_q);EEPROM.update(14,loud_f);EEPROM.update(15,loud_g);
     EEPROM.update(16,lf+79);EEPROM.update(17,rf+79);EEPROM.update(18,lr+79);EEPROM.update(19,rr+79);EEPROM.update(20,sub+79);EEPROM.update(21,sub_f);
     EEPROM.update(22,faza);
     EEPROM.update(30,gain4);EEPROM.update(31,gain5);EEPROM.update(32,gain6);EEPROM.update(33,gain7);EEPROM.update(34,gain8);EEPROM.update(35,gain9);EEPROM.update(36,gain10);
     menu=0;menu_1=0;menu_2=0;w=0;w2_arr();}
  
  }// loop

void faza_func(){if(faza>1){faza=0;}if(faza<0){faza=1;}}   
void sub_f_func(){if(sub_f>4){sub_f=0;}if(sub_f<0){sub_f=4;}}
void lf_func(){if(lf<-79){lf=-79;}if(lf>15){lf=15;}};
void rf_func(){if(rf<-79){rf=-79;}if(rf>15){rf=15;}};
void lr_func(){if(lr<-79){lr=-79;}if(lr>15){lr=15;}};
void rr_func(){if(rr<-79){rr=-79;}if(rr>15){rr=15;}};
void sub_func(){if(sub<-79){sub=-79;}if(sub>15){sub=15;}};
void au(){if(www==1){audio();www=0;}}
void loud_f_func(){if(loud_f>3){loud_f=0;}if(loud_f<0){loud_f=3;}}
void loud_g_func(){if(loud_g>20){loud_g=20;}if(loud_g<0){loud_g=0;}}
void mid_q_func(){if(mid_q>3){mid_q=0;}if(mid_q<0){mid_q=3;}}
void treb_q_func(){if(treb_q>1){treb_q=0;}if(treb_q<0){treb_q=1;}}
void bass_q_func(){if(bass_q>3){bass_q=0;}if(bass_q<0){bass_q=3;}}
void mid_f_func(){if(mid_f>3){mid_f=0;}if(mid_f<0){mid_f=3;}}
void treb_f_func(){if(treb_f>3){treb_f=0;}if(treb_f<0){treb_f=3;}}
void bass_f_func(){if(bass_f>3){bass_f=0;}if(bass_f<0){bass_f=3;}}
void gain_func(){if(gain0<0){gain0=0;}if(gain0>20){gain0=20;}}
void bass_func(){if(bass>20){bass=20;}if(bass<-20){bass=-20;}} 
void mid_func(){if(mid>20){mid=20;}if(mid<-20){mid=-20;}}
void treb_func(){if(treb>20){treb=20;}if(treb<-20){treb=-20;}}
void vol_func(){if(vol<-79){vol=-79;}if(vol>15){vol=15;}}
void w2_arr(){w2[0]=1;w2[1]=1;w2[2]=1;w2[3]=1;}
void cl(){ir.value=0;delay(300);lcd.clear();}
void cl1(){ir.value=0;delay(200);}  


void audio(){
   bd.setSetup_1(1,2,0); // default (1,2,0)
   bd.setSetup_2(sub_f,1,0,faza); 
                   // int sub_f ------ OFF 55Hz 85Hz 120Hz 160Hz = int 0...4
                   // int sub_out ---- LPF Front Rear Prohibition = int 0...3
                   // int level_metr - HOLD REST = int 0..1
                   // int faza ------- 0 180 = int 0...1
   bd.setLoudness_f(loud_f); // 250Hz 400Hz 800Hz Prohibition = int 0...3
   bd.setIn(in); // 0...2
   bd.setIn_gain(gain0,mute); // in_gain -- 0...20 = 0...20 dB, mute -- 0 default 
   bd.setVol(vol); // -79...+15 dB = int -79...15
   bd.setFront_1(rf); // -79...+15 dB = int -79...15
   bd.setFront_2(lf); // -79...+15 dB = int -79...15
   bd.setRear_1(rr); // -79...+15 dB = int -79...15
   bd.setRear_2(lr); // -79...+15 dB = int -79...15
   bd.setSub(sub); // -79...+15 dB = int -79...15
   bd.mix();
   bd.setBass_setup(bass_q,bass_f); // 0.5 1.0 1.5 2.0 --- int 0...3, 60Hz 80Hz 100Hz 120Hz --- int 0...3
   bd.setMiddle_setup(mid_q,mid_f); // 0.75 1.0 1.25 1.5 --- int 0...3, 500Hz 1kHz 1.5kHz 2.5kHz --- int 0...3
   bd.setTreble_setup(treb_q,treb_f); // 0.75 1.25  --- int 0...1, 7.5kHz 10kHz 12.5kHz 15kHz --- int 0...3
   bd.setBass_gain(bass); // --20 ... +20 dB = int -20 ... 20  
   bd.setMiddle_gain(mid); // --20 ... +20 dB = int -20 ... 20
   bd.setTreble_gain(treb); // --20 ... +20 dB = int -20 ... 20   
   bd.setLoudness_gain(loud_g); // 0 ... 20 dB = int 0 ... 20
  }  

void to_Timer(){newPosition = myEnc.read()/4;}  

111

Re: BD37534FV+LCD2004+энкодер+ИК пульт

Александр, вроде заработал, переключает 10 входов, Благодарю!

112 (2023-03-13 19:05:59 отредактировано Allkor)

Re: BD37534FV+LCD2004+энкодер+ИК пульт

Извините пожалуйста. Опять я со своей проблеммой. Причину нашел. Дело в скетче.
У меня кнопки и энкодер на печатке собраны по этой схеме
http://forum.rcl-radio.ru/uploads/images/2023/03/8713fb013482b6e8876826616d545490.jpg
Перемычка стоит на D10.  Сопротивления 10к идут по минусу.
Поэтому ваш скетч с 81 поста не работал с моей схемой подключения..
Дело наверно в пинах D6, D4, D2 .

http://forum.rcl-radio.ru/uploads/images/2023/03/a723d388c1c538eb735a53db6d27aead.jpg

Пробовал переназначить кнопки, но у меня все равно не работает.
Не могли бы вы подправить скетч с 81 поста под мою конфигурацию.

113

Re: BD37534FV+LCD2004+энкодер+ИК пульт

#define IR_1 0xFF629D // Кнопка вверх
#define IR_2 0xFFA857 // Кнопка вниз 
#define IR_3 0xFFC23D // Кнопка >
#define IR_4 0xFF22DD // Кнопка <
#define IR_5 0xFFE01F // Кнопка IN 
#define IR_6 0xFF02FD // Кнопка MENU2 
#define IR_7 0xFFE21D // Кнопка MUTE 
#define IR_8 0xFFA25D // Кнопка STANDBY (POWER)
/*
#define IR_1 0x33B8A05F // Кнопка вверх
#define IR_2 0x33B8609F // Кнопка вниз 
#define IR_3 0x33B810EF // Кнопка >
#define IR_4 0x33B8E01F // Кнопка <
#define IR_5 0x33B844BB // Кнопка IN 
#define IR_6 0x33B8946B // Кнопка MENU2  
#define IR_7 0x33B850AF // Кнопка MUTE 
#define IR_8 0x33B800FF // Кнопка STANDBY (POWER)
*/

#define SW     2
#define IN     3
#define MENU2  4
#define MUTE   6
#define POWER  5
#define OUT_ST 7

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>  // http://forum.rcl-radio.ru/misc.php?action=pan_download&item=45&download=1
#include <BD37534FV.h>          // https://github.com/liman324/BD37534FV/archive/master.zip
#include <Encoder.h>            // http://rcl-radio.ru/wp-content/uploads/2019/05/Encoder.zip
#include <EEPROM.h>
#include <MsTimer2.h>           // http://rcl-radio.ru/wp-content/uploads/2018/11/MsTimer2.zip
#include <boarddefs.h>
#include <IRremote.h>           // http://rcl-radio.ru/wp-content/uploads/2019/06/IRremote.zip
   BD37534FV bd; 
   LiquidCrystal_I2C lcd(0x27,20,4);  // Устанавливаем дисплей
   IRrecv irrecv(12); // указываем вывод модуля IR приемника
   Encoder myEnc(9, 8);// DT, CLK
   decode_results ir; 
   byte a1[8] = {0b00000,0b10101,0b10101,0b10101,0b10101,0b10101,0b10101,0b00000};
   byte a2[8] = {0b00000,0b10100,0b10100,0b10100,0b10100,0b10100,0b10100,0b00000};
   byte a3[8] = {0b00000,0b10000,0b10000,0b10000,0b10000,0b10000,0b10000,0b00000}; 
   byte a4[8] = {0b10000,0b11000,0b11100,0b11110,0b11100,0b11000,0b10000,0b00000}; 
   unsigned long time,times_in,oldPosition  = -999,newPosition; 
   byte in,in_x,w,w1,w2[4],w3,z,z0,z1,q,i,n,www,gr1,gr2,mute,power;
   int menu,menu0,menu_1,menu_2,vol,bass,treb,mid,vol_d,bass_d,treb_d,mid_d;
   int temp0,gain0,gain1,gain2,gain3,gain_d;
   int bass_f,bass_q,treb_f,treb_q,mid_f,mid_q,loud_f,loud_g;
   int lf,rf,lr,rr,sub,sub_f,faza,par;
   byte mesto[8]={4,13,4,13,4,13,4,13};
   byte mesto1[8]={0,0,1,1,2,2,3,3};
   byte mesto2[7]={0,11,0,11,11,0,11};
   byte mesto3[7]={0,0,1,1,2,3,3};
   String bass_nam[4]={"60   Hz", "80   Hz", "100  Hz", "120  Hz"};
   String treb_nam[4]={"7.5 kHz", "10  kHz", "12.5kHz", "15  kHz"};
   String mid_nam[4] ={"500  Hz", "1   kHz", "1.5 kHz", "2.5 kHz"};
   String lon_nam[4] ={"250  Hz", "400  Hz", "800  Hz", "disable"};
   String sub_nam[5] ={" OFF   ", " 55  Hz", " 85  Hz", " 120 Hz", " 160 Hz"};
   float bass_nam_1[4]={0.5, 1.0, 1.5, 2.0};
   float mid_nam_1[4]={0.75, 1.0, 1.25, 1.5};
   float treb_nam_1[2]={0.75, 1.25};

void setup() {Serial.begin(9600);
  irrecv.enableIRIn();lcd.init();lcd.backlight();
  lcd.setCursor(0,1);lcd.print("    PRIVET RAIL");lcd.setCursor(0,2);lcd.print("        ***"); delay(2000);
  lcd.createChar(0,a1);lcd.createChar(1,a2);lcd.createChar(2,a3);lcd.createChar(3,a4);
  pinMode(SW,INPUT);  // МЕНЮ КНОПКА SW энкодера
  pinMode(MENU2,INPUT);   // МЕНЮ НАСТРОЕК
  pinMode(IN,INPUT);   // IN
  pinMode(MUTE,INPUT);// КНОПКА MUTE
  pinMode(POWER,INPUT);// КНОПКА STANDBY
  pinMode(OUT_ST,OUTPUT);//  STANDBY
  MsTimer2::set(3, to_Timer);MsTimer2::start();
  if(EEPROM.read(100)!=0){for(int i=0;i<100;i++){EEPROM.update(i,0);}}// очистка памяти при первом включении 
  vol = EEPROM.read(0)-79;treb = EEPROM.read(1)-20;mid = EEPROM.read(2)-20;bass = EEPROM.read(3)-20;
  in = EEPROM.read(4);gain1 = EEPROM.read(5);gain2 = EEPROM.read(6);gain3 = EEPROM.read(7);
  bass_f = EEPROM.read(8);bass_q = EEPROM.read(9);treb_f = EEPROM.read(10);treb_q = EEPROM.read(11);
  mid_f = EEPROM.read(12);mid_q = EEPROM.read(13);loud_f = EEPROM.read(14);loud_g= EEPROM.read(15);
  lf = EEPROM.read(16)-79;rf = EEPROM.read(17)-79;lr = EEPROM.read(18)-79;rr = EEPROM.read(19)-79;sub = EEPROM.read(20)-79;sub_f = EEPROM.read(21);
  faza = EEPROM.read(22);
  w2_arr();audio();cl();
}

void loop(){
  if(mute==0){
  if(digitalRead(SW)==LOW&&menu0==0){menu++;delay(200);time=millis();w=1;w2_arr();if(menu>3){menu=0;}}// меню 0
  if(digitalRead(SW)==LOW&&menu0==1){menu_1++;delay(200);time=millis();w=1;if(menu_1>7){menu_1=0;}}// меню 1
  if(digitalRead(SW)==LOW&&menu0==2){menu_2++;delay(200);time=millis();w=1;if(menu_2>6){menu_2=0;}}// меню 2
 
  if(digitalRead(MENU2)==HIGH){menu0++;cl();delay(200);time=millis();w=1;w2_arr();menu=0;menu_1=0;menu_2=0;if(menu0>2){menu0=0;}}// меню
  if(digitalRead(IN)==HIGH){in++;cl();times_in=millis();in_x=1;w3=1;www=1;menu0=100;if(in>2){in=0;}}// IN
  }
  if(digitalRead(MUTE)==HIGH&&mute==0&&power==0){mute=1;cl();w=1;w2_arr();lcd.setCursor(8,1);lcd.print("MUTE");menu0=100;audio();}// mute on
  if(digitalRead(MUTE)==HIGH&&mute==1&&power==0){mute=0;cl();time=millis();w=1;w2_arr();menu0=0;myEnc.write(0);audio();}// mute off

  if(digitalRead(POWER)==HIGH&&power==0){power=1;mute=1;audio();lcd.clear();lcd.setCursor(5,1);lcd.print("POWER  OFF");menu0=100;delay(3000);lcd.noBacklight();}// power off
  if(digitalRead(POWER)==HIGH&&power==1){power=0;mute=0;audio();lcd.backlight();lcd.clear();lcd.setCursor(5,1);lcd.print("POWER   ON ");w=1;w2_arr();menu0=0;myEnc.write(0);audio();delay(3000);lcd.clear();}// power on
  if(power==0){digitalWrite(OUT_ST,HIGH);}if(power==1){digitalWrite(OUT_ST,LOW);} // выход STANDBY

  ////////////////////// IR /////////////////////////////////////////////////
  if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);irrecv.resume();time=millis();w=1;}// IR приемник - чтение, в мониторе порта отображаются коды кнопок
  if(ir.value==0){gr1=0;gr2=0;}// запрет нажатий не активных кнопок пульта
   if(mute==0){
   if(ir.value==IR_2&&menu0==0){menu++;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu>3){menu=0;}}//  кнопка вверх 
   if(ir.value==IR_1&&menu0==0){menu--;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu<0){menu=3;}}//  кнопка вниз
   if(ir.value==IR_2&&menu0==1){menu_1++;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu_1>7){menu_1=0;}}//  кнопка вверх 
   if(ir.value==IR_1&&menu0==1){menu_1--;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu_1<0){menu_1=7;}}//  кнопка вниз
   if(ir.value==IR_2&&menu0==2){menu_2++;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu_2>6){menu_2=0;}}//  кнопка вверх 
   if(ir.value==IR_1&&menu0==2){menu_2--;gr1=0;gr2=0;cl1();time=millis();w=1;if(menu_2<0){menu_2=6;}}//  кнопка вниз
 
   if(ir.value==IR_6){menu0++;in_x=0;gr1=0;gr2=0;cl();time=millis();w=1;w2_arr();menu=0;menu_1;menu_2;if(menu0>2){menu0=0;}}//  кнопка MENU
   if(ir.value==IR_5){in++;gr1=0;gr2=0;cl();times_in=millis();in_x=1;w3=1;www=1;menu0=100;if(in>2){in=0;}}//  кнопка IN
   }
   if(ir.value==IR_7&&mute==0&&power==0){mute=1;cl();w=1;w2_arr();lcd.setCursor(8,1);lcd.print("MUTE");menu0=100;audio();}// mute on
   if(ir.value==IR_7&&mute==1&&power==0){mute=0;cl();time=millis();w=1;w2_arr();menu0=0;myEnc.write(0);audio();}// mute off

   if(ir.value==IR_8&&power==0){power=1;mute=1;audio();cl();lcd.setCursor(5,1);lcd.print("POWER  OFF");menu0=100;delay(3000);lcd.noBacklight();}// power off
   if(ir.value==IR_8&&power==1){power=0;mute=0;audio();lcd.backlight();cl();lcd.setCursor(5,1);lcd.print("POWER   ON ");w=1;w2_arr();menu0=0;myEnc.write(0);audio();delay(3000);lcd.clear();}// power on
   
   /////////////////////////////// MENU0 = VOLUME TERBLE MIDDLE BASS ///////////////////////////////////////////////////////////////////////
  if(menu0==0){
    switch(menu){
      case 0: temp0 = vol;q=0;break;
      case 1: temp0 = treb;q=1;break;
      case 2: temp0 = mid;q=2;break;
      case 3: temp0 = bass;q=3;break;
      }
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time=millis();w=1;w2[q]=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time=millis();;w=1;w2[q]=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time=millis();;w=1;w2[q]=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time=millis();w=1;w2[q]=1;www=1;}// кнопка <<<<<<   
 
   if (newPosition != oldPosition){oldPosition = newPosition;
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;w2[q]=1;www=1;} 
 
     switch(menu){
      case 0: vol = temp0;vol_func();break;
      case 1: treb = temp0;treb_func();break;
      case 2: mid = temp0;mid_func();break;
      case 3: bass = temp0;bass_func();break;
      }
 
   au();
   for(i=0;i<4;i++){if(menu==i){lcd.setCursor(0,i);lcd.write((uint8_t)3);}else{lcd.setCursor(0,i);lcd.print(" ");}}
   lcd.setCursor(1,0);lcd.print("VOLUME ");if(map(vol,-79,15,0,100)<10){lcd.print(" ");}if(map(vol,-79,15,0,100)<100){lcd.print(" ");}
     lcd.print(map(vol,-79,15,0,100));lcd.print(" ");vol_d=map(vol,-79,15,0,21);
   lcd.setCursor(1,1);lcd.print("TREBLE ");if(treb>-10){lcd.print(" ");}if(treb<10&&treb>=0){lcd.print(" ");}
     lcd.print(treb);lcd.print(" ");treb_d=map(treb,-20,20,0,21);
   lcd.setCursor(1,2);lcd.print("MIDDLE ");if(mid>-10){lcd.print(" ");}if(mid<10&&mid>=0){lcd.print(" ");}
     lcd.print(mid);lcd.print(" ");mid_d=map(mid,-20,20,0,21);
   lcd.setCursor(1,3);lcd.print("BASS   ");if(bass>-10){lcd.print(" ");}if(bass<10&&bass>=0){lcd.print(" ");}
     lcd.print(bass);lcd.print(" ");bass_d=map(bass,-20,20,0,21);
   
   for(n=0;n<4;n++){if(w2[n]==1){
   switch(n){
    case 0: par = vol_d;break;
    case 1: par = treb_d;break;
    case 2: par = mid_d;break;
    case 3: par = bass_d;break;
    } 
   for(z=0,z0=0,z1=0;z<=par;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+12,n);lcd.write((uint8_t)0);lcd.setCursor(z0+1+12,n);lcd.print("  ");}}
   if(z1==3){lcd.setCursor(z0+12,n);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+12,n);lcd.write((uint8_t)2);}w2[n]=0;}
   }}// menu0 = 0
///////////////////////////////////////////////////////////////////////////////////////////////
  
 ///////////////////// MENU 2 ////////////////////////////////////////////////////////
 if(menu0==1){
  switch(menu_1){
      case 0: temp0 = bass_f;break;
      case 1: temp0 = bass_q;break;
      case 2: temp0 = mid_f;break;
      case 3: temp0 = mid_q;break;
      case 4: temp0 = treb_f;break;
      case 5: temp0 = treb_q;break;
      case 6: temp0 = loud_f;break;
      case 7: temp0 = loud_g;break;}
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time=millis();w=1;www=1;}// кнопка > 
   //  if(ir.value==0xFFFFFFFF and gr1==1){temp0++;gr2=0;cl1();time=millis();w=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time=millis();;w=1;www=1;}// кнопка <
   //  if(ir.value==0xFFFFFFFF and gr2==1){temp0--;gr1=0;cl1();time=millis();w=1;www=1;}// кнопка <<<<<<     
 
   if (newPosition != oldPosition){oldPosition = newPosition;
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;www=1;} 
 
     switch(menu_1){
      case 0: bass_f = temp0;bass_f_func();break;
      case 1: bass_q = temp0;bass_q_func();break;
      case 2: mid_f = temp0;mid_f_func();break;
      case 3: mid_q = temp0;mid_q_func();break;
      case 4: treb_f = temp0;treb_f_func();break;
      case 5: treb_q = temp0;treb_q_func();break;
      case 6: loud_f = temp0;loud_f_func();break;
      case 7: loud_g = temp0;loud_g_func();break;}
 
  au();
  for(i=0;i<8;i++){if(menu_1==i){lcd.setCursor(mesto[i],mesto1[i]);lcd.write((uint8_t)3);}else{lcd.setCursor(mesto[i],mesto1[i]);lcd.print(" ");}}
  lcd.setCursor(0,0);lcd.print("BASS");lcd.setCursor(5,0);lcd.print(bass_nam[bass_f]);lcd.setCursor(14,0);lcd.print("Q ");lcd.print(bass_nam_1[bass_q]);
  lcd.setCursor(0,1);lcd.print("MIDD");lcd.setCursor(5,1);lcd.print(mid_nam[mid_f]);lcd.setCursor(14,1);lcd.print("Q ");lcd.print(mid_nam_1[mid_q]);
  lcd.setCursor(0,2);lcd.print("TREB");lcd.setCursor(5,2);lcd.print(treb_nam[treb_f]);lcd.setCursor(14,2);lcd.print("Q ");lcd.print(treb_nam_1[treb_q]);
  lcd.setCursor(0,3);lcd.print("LOUD");lcd.setCursor(5,3);lcd.print(lon_nam[loud_f]);lcd.setCursor(14,3);lcd.print("G ");lcd.print(loud_g/10);lcd.print(loud_g%10);lcd.setCursor(18,3);lcd.print("dB");
  }// menu0 = 1
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

  if(menu0==2){
     switch(menu_2){
      case 0: temp0 = lf;break;
      case 1: temp0 = rf;break;
      case 2: temp0 = lr;break;
      case 3: temp0 = rr;break;
      case 4: temp0 = faza;break;
      case 5: temp0 = sub;break;
      case 6: temp0 = sub_f;break;}
 
     if(ir.value==IR_3){temp0++;gr1=1;gr2=0;cl1();time=millis();w=1;www=1;}// кнопка > 
     if(ir.value==0xFFFFFFFF && gr1==1){temp0++;gr2=0;cl1();time=millis();w=1;www=1;}// кнопка >>>>>>
     if(ir.value==IR_4){temp0--;gr1=0;gr2=1;cl1();time=millis();;w=1;www=1;}// кнопка <
     if(ir.value==0xFFFFFFFF && gr2==1){temp0--;gr1=0;cl1();time=millis();w=1;www=1;}// кнопка <<<<<<     
 
   if (newPosition != oldPosition){oldPosition = newPosition;
     temp0=temp0+newPosition;myEnc.write(0);newPosition=0;time=millis();w=1;www=1;} 
 
     switch(menu_2){
      case 0: lf = temp0;lf_func();break;
      case 1: rf = temp0;rf_func();break;
      case 2: lr = temp0;lr_func();break;
      case 3: rr = temp0;rr_func();break;
      case 4: faza = temp0;faza_func();break;
      case 5: sub = temp0;sub_func();break;
      case 6: sub_f = temp0;sub_f_func();break;}
 
  au();
  for(i=0;i<7;i++){if(menu_2==i){lcd.setCursor(mesto2[i],mesto3[i]);lcd.write((uint8_t)3);}else{lcd.setCursor(mesto2[i],mesto3[i]);lcd.print(" ");}}
  lcd.setCursor(1,0);lcd.print("LF");lcd.setCursor(4,0);lcd.print(lf);lcd.print(" ");lcd.setCursor(7,0);lcd.print("dB ");lcd.setCursor(12,0);lcd.print("RF ");lcd.print(rf);lcd.print(" ");lcd.setCursor(18,0);lcd.print("dB");
  lcd.setCursor(1,1);lcd.print("LR");lcd.setCursor(4,1);lcd.print(lr);lcd.print(" ");lcd.setCursor(7,1);lcd.print("dB ");lcd.setCursor(12,1);lcd.print("RR ");lcd.print(rr);lcd.print(" ");lcd.setCursor(18,1);lcd.print("dB");
  lcd.setCursor(1,2);lcd.print("Subwoofer");lcd.setCursor(12,2);lcd.print("Faza ");if(faza==0){lcd.print("  0");}else{lcd.print("180");}
  lcd.setCursor(1,3);lcd.print("G ");lcd.setCursor(4,3);lcd.print(sub);lcd.print(" ");lcd.setCursor(7,3);lcd.print("dB ");lcd.setCursor(12,3);lcd.print(sub_nam[sub_f]);
 } // menu0 = 2


 ////////////////////////// GAIN IN /////////////////////////////////////////////////////////////////////////////////////
if(in_x==1){ menu0=100;
   switch(in){
     case 0: gain0 = gain1;break;
     case 1: gain0 = gain2;break;
     case 2: gain0 = gain3;break;}
 
     if(ir.value==IR_3){gain0++;gr1=1;gr2=0;cl1();time=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка > 
     if(ir.value==0xFFFFFFFF and gr1==1){gain0++;gr2=0;cl1();time=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка >>>>>>
     if(ir.value==IR_4){gain0--;gr1=0;gr2=1;cl1();time=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка <
     if(ir.value==0xFFFFFFFF and gr2==1){gain0--;gr1=0;cl1();time=millis();times_in=millis();www=1;w=1;w3=1;gain_func();}// кнопка <<<<<<  
 
    if (newPosition != oldPosition) {oldPosition = newPosition;
    gain0=gain0+newPosition;myEnc.write(0);newPosition=0;time=millis();times_in=millis();www=1;w=1;w3=1;gain_func();} 
 
   switch(in){
     case 0: gain1 = gain0;break;
     case 1: gain2 = gain0;break;
     case 2: gain3 = gain0;break;}
 
  au();
  lcd.setCursor(2,1);lcd.print("BXOD ");
  switch(in){
    case 0: lcd.print("MP3");break;
    case 1: lcd.print(" TV");break;
    case 2: lcd.print("AUX");break;
    }
  lcd.setCursor(11,1);lcd.print(" ");lcd.print(gain0);lcd.print(" ");lcd.setCursor(15,1);lcd.print("dB");gain_d=gain0+1;
   if(w3==1){
   for(z=0,z0=0,z1=0;z<=gain_d;z++,z1++){if(z1>2){z1=0;z0++;}
   if(z1==1){lcd.setCursor(z0+7,2);lcd.write((uint8_t)0);lcd.setCursor(z0+1+7,2);lcd.print("   ");}}
   if(z1==3){lcd.setCursor(z0+7,2);lcd.write((uint8_t)1);}
   if(z1==2){lcd.setCursor(z0+7,2);lcd.write((uint8_t)2);}} w3=0;
   if(millis()-times_in>3000){in_x=0;cl();menu0=0;w2_arr();}}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////   
 
  
  ///////////////////// EEPROM ///////////////////////////////////////////////////////////////         
  if(millis()-time>10000 && w==1){
     EEPROM.update(0,vol+79);EEPROM.update(1,treb+20);EEPROM.update(2,mid+20);EEPROM.update(3,bass+20);
     EEPROM.update(4,in);EEPROM.update(5,gain1);EEPROM.update(6,gain2);EEPROM.update(7,gain3);
     EEPROM.update(8,bass_f);EEPROM.update(9,bass_q);EEPROM.update(10,treb_f);EEPROM.update(11,treb_q),
     EEPROM.update(12,mid_f);EEPROM.update(13,mid_q);EEPROM.update(14,loud_f);EEPROM.update(15,loud_g);
     EEPROM.update(16,lf+79);EEPROM.update(17,rf+79);EEPROM.update(18,lr+79);EEPROM.update(19,rr+79);EEPROM.update(20,sub+79);EEPROM.update(21,sub_f);
     EEPROM.update(22,faza);
     menu=0;menu_1=0;menu_2=0;w=0;w2_arr();}
  
  }// loop

void faza_func(){if(faza>1){faza=1;}if(faza<0){faza=0;}}   
void sub_f_func(){if(sub_f>4){sub_f=4;}if(sub_f<0){sub_f=0;}}
void lf_func(){if(lf<-79){lf=-79;}if(lf>15){lf=15;}};
void rf_func(){if(rf<-79){rf=-79;}if(rf>15){rf=15;}};
void lr_func(){if(lr<-79){lr=-79;}if(lr>15){lr=15;}};
void rr_func(){if(rr<-79){rr=-79;}if(rr>15){rr=15;}};
void sub_func(){if(sub<-79){sub=-79;}if(sub>15){sub=15;}};
void au(){if(www==1){audio();www=0;}}
void loud_f_func(){if(loud_f>3){loud_f=3;}if(loud_f<0){loud_f=0;}}
void loud_g_func(){if(loud_g>20){loud_g=20;}if(loud_g<0){loud_g=0;}}
void mid_q_func(){if(mid_q>3){mid_q=3;}if(mid_q<0){mid_q=0;}}
void treb_q_func(){if(treb_q>1){treb_q=1;}if(treb_q<0){treb_q=0;}}
void bass_q_func(){if(bass_q>3){bass_q=3;}if(bass_q<0){bass_q=0;}}
void mid_f_func(){if(mid_f>3){mid_f=3;}if(mid_f<0){mid_f=0;}}
void treb_f_func(){if(treb_f>3){treb_f=3;}if(treb_f<0){treb_f=0;}}
void bass_f_func(){if(bass_f>3){bass_f=3;}if(bass_f<0){bass_f=0;}}
void gain_func(){if(gain0<0){gain0=0;}if(gain0>20){gain0=20;}}
void bass_func(){if(bass>20){bass=20;}if(bass<-20){bass=-20;}} 
void mid_func(){if(mid>20){mid=20;}if(mid<-20){mid=-20;}}
void treb_func(){if(treb>20){treb=20;}if(treb<-20){treb=-20;}}
void vol_func(){if(vol<-79){vol=-79;}if(vol>15){vol=15;}}
void w2_arr(){w2[0]=1;w2[1]=1;w2[2]=1;w2[3]=1;}
void cl(){ir.value=0;delay(300);lcd.clear();}
void cl1(){ir.value=0;delay(200);}  


void audio(){
   bd.setSetup_1(1,2,0); // default (1,2,0)
   bd.setSetup_2(sub_f,1,0,faza); 
                   // int sub_f ------ OFF 55Hz 85Hz 120Hz 160Hz = int 0...4
                   // int sub_out ---- LPF Front Rear Prohibition = int 0...3
                   // int level_metr - HOLD REST = int 0..1
                   // int faza ------- 0 180 = int 0...1
   bd.setLoudness_f(loud_f); // 250Hz 400Hz 800Hz Prohibition = int 0...3
   bd.setIn(in); // 0...2
   bd.setIn_gain(gain0,mute); // in_gain -- 0...20 = 0...20 dB, mute -- 0 default 
   bd.setVol(vol); // -79...+15 dB = int -79...15
   bd.setFront_1(rf); // -79...+15 dB = int -79...15
   bd.setFront_2(lf); // -79...+15 dB = int -79...15
   bd.setRear_1(rr); // -79...+15 dB = int -79...15
   bd.setRear_2(lr); // -79...+15 dB = int -79...15
   bd.setSub(sub); // -79...+15 dB = int -79...15
   bd.mix();
   bd.setBass_setup(bass_q,bass_f); // 0.5 1.0 1.5 2.0 --- int 0...3, 60Hz 80Hz 100Hz 120Hz --- int 0...3
   bd.setMiddle_setup(mid_q,mid_f); // 0.75 1.0 1.25 1.5 --- int 0...3, 500Hz 1kHz 1.5kHz 2.5kHz --- int 0...3
   bd.setTreble_setup(treb_q,treb_f); // 0.75 1.25  --- int 0...1, 7.5kHz 10kHz 12.5kHz 15kHz --- int 0...3
   bd.setBass_gain(bass); // --20 ... +20 dB = int -20 ... 20  
   bd.setMiddle_gain(mid); // --20 ... +20 dB = int -20 ... 20
   bd.setTreble_gain(treb); // --20 ... +20 dB = int -20 ... 20   
   bd.setLoudness_gain(loud_g); // 0 ... 20 dB = int 0 ... 20
  }  

void to_Timer(){newPosition = myEnc.read()/4;}   

114

Re: BD37534FV+LCD2004+энкодер+ИК пульт

Сейчас с кнопок все работает. Входы переключаются, громкость регулируется. Но когда открываю любое меню, курсор в круговую бегает гр-выс-ср-низ-гр-.
пробовал энкодер сажать и н + и на -. На +  курсор бегает по строкам, на - не реагирует.
Пробовал перекинуть на  D10 и перекидывать питание энк +/-., результата нет.
Еще раз проверил.  Питание энкодера +5. SW соединен D2.  D10 висит в воздухе.

115

Re: BD37534FV+LCD2004+энкодер+ИК пульт

Если не нажимать кнопку энкодера на выходе sw есть +5В?

116

Re: BD37534FV+LCD2004+энкодер+ИК пульт

+5в sw присутствует на самом энкодере.

117

Re: BD37534FV+LCD2004+энкодер+ИК пульт

Подайте на D2 +5В через резистор 4,7-10 к.

Курсор остановиться?

118

Re: BD37534FV+LCD2004+энкодер+ИК пульт

Если не поможет поменяйте вход энкодера
#define SW     2

замените на любой свободный, например на D10

#define SW     10

119

Re: BD37534FV+LCD2004+энкодер+ИК пульт

заменил энкодер, не помагло.

120

Re: BD37534FV+LCD2004+энкодер+ИК пульт

#define SW     2 заменил на 10, не помогло.
В какой то момент перестали регулироваться громкость входов. не понял когда это произошло. Только заметил.

121

Re: BD37534FV+LCD2004+энкодер+ИК пульт

У Вас все верно подключено?

#define SW     2
#define IN     3
#define MENU2  4
#define MUTE   6
#define POWER  5
#define OUT_ST 7

Encoder myEnc(9, 8);// DT, CLK

Все должно работать, в коде ошибок не вижу.

122

Re: BD37534FV+LCD2004+энкодер+ИК пульт

У меня шлейфы распаяны давно, они работали. Как один раз спаял больше не трогал.
+5
3 d3 in
4 d4 menu
5 d5 power
6 d6 mute
Последовательность пока не интересует.
Пробовал только на энкодере питание менять.
Сопротивления впаяну в плату.
http://forum.rcl-radio.ru/uploads/images/2023/03/8c071fbe3ce4f1b8e38e947c71ed7a4e.jpeg
http://forum.rcl-radio.ru/uploads/images/2023/03/98d587a892e9678f62f92e22124e5563.jpeg
http://forum.rcl-radio.ru/uploads/images/2023/03/c7e41a2416f071146d7c026a0af66bc5.jpeg
http://forum.rcl-radio.ru/uploads/images/2023/03/3a3a602973314e5e7b90bbdde985c2dd.jpeg

Наверно оставлю на завтра. Надо домой ехать, устал и голоден.

123

Re: BD37534FV+LCD2004+энкодер+ИК пульт

http://forum.rcl-radio.ru/uploads/images/2023/04/0a55c67c56b2af9863419b6521891e8b.jpg

124

Re: BD37534FV+LCD2004+энкодер+ИК пульт

String dn[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};

String dn[]={"   ", "SUN","MON","TUE","WED","THU","FRI","SAT"};

125

Re: BD37534FV+LCD2004+энкодер+ИК пульт

спасибо заработала