1

Тема: Восстановление акустической системы MB SOUND MB-2780PF

Замена контроллера на Arduino

http://forum.rcl-radio.ru/uploads/images/2020/04/6af842376f84a84cc45eac0f1c9779e4.png

http://forum.rcl-radio.ru/uploads/images/2020/04/a79eeed3f1e624c0efbba2e8abfbf82d.png

http://forum.rcl-radio.ru/uploads/images/2020/04/5d440eff2d7fed6ac12b623f7754dd11.png


Библиотека - Данный контент доступен только зарегистрированным пользователям.




1. Активация аудиопроцессора
2. Регулировка громкости (A0 A1 - коммутация кнопки на землю(без резисторов))
3. Индикация нажатия кнопок громкости (D4 D5) и светодиодов громкости
4. Активирован пульт

#define POWER    0xF7AA55            // гасим все светодиоды + MUTE
#define MUTE     0xF7EA15   //  OK
#define DVD      0xF7B24D   //  OK   // включение 6-и канального входа
#define STEREO   0xF7F20D   //  OK   // включение AUX
#define AUX1     0xF7926D   //  OK   // выбор AUX
#define AUX2     0xF7D22D   //  OK
#define CH5_1    0xF7A25D   //  OK   //  активен выход 5,1
#define CH2_1    0xF7E21D   //  OK   //  активен выход 2,1 (фронт и саб)
#define VOL_UP   0xF7728D   //  OK
#define SUB_DW   0xF742BD   //  OK
#define SUB_UP   0xF75AA5   //  OK
#define VOL_DW   0xF76A95   //  OK
#define FRONT_DW 0xF7A05F   //  OK
#define FRONT_UP 0xF720DF   //  OK
#define REAR_DW  0xF7906F   //  OK
#define REAR_UP  0xF710EF   //  OK
#define CEN_DW   0xF7B04F   //  OK
#define CEN_UP   0xF730CF   //  OK
#define TREB_UP  0xF78877   //  OK
#define TREB_DW  0xF708F7   //  OK
#define BASS_UP  0xF7A857   //  OK
#define BASS_DW  0xF728D7   //  OK
#define RESET    0xF738C7            //  ??????????????
 
#include <R2S15902FP.h>// http://forum.rcl-radio.ru/misc.php?action=pan_download&item=517&download=1
#include <EEPROM.h>
#include <boarddefs.h>
#include <IRremote.h>  // http://rcl-radio.ru/wp-content/uploads/2019/06/IRremote.zip
  IRrecv irrecv(12); // указываем вывод модуля IR приемника
  decode_results ir; 
  int vol,vol_old,vol_sound,in,treb,bass,front,cc,sub,rear,bbb;
  unsigned long times;
  byte w,l_r,mute,gr1,gr2,q1,q2,q3,q4,q5,q6,out,powers,blok;
 
void setup(){ //Serial.begin(9600);
  irrecv.enableIRIn();
  ///////////  Подключение 
  // BUTTON 
  pinMode (A0,INPUT_PULLUP); // VOL +   // A0  OK
  pinMode (A1,INPUT_PULLUP); // VOL -   // A1  OK
  pinMode (A2,INPUT_PULLUP); // 5.1CH  ON/OFF  // A2  OK
  pinMode (A3,INPUT_PULLUP); // STEREO ON/OFF // A3  OK
  pinMode (A4,INPUT_PULLUP); // AUX     // A4  OK
  pinMode (A5,INPUT_PULLUP); // MODE    // A5  OK = 6IN
  pinMode (A6,INPUT); // POWER   // A6 
  // LED 
  pinMode(0,OUTPUT); // LED 5.1CH_BLUE  // D0  OK
  pinMode(1,OUTPUT); // LED STEREO_RED  // D1  0K
  // audio processor
  pinMode(DATA, OUTPUT);  // DATA       // D2  OK
  pinMode(CLK, OUTPUT);   // CLK        // D3  OK
  // LED
  pinMode(4,OUTPUT); // LED VOLUME UP   // D4  OK
  pinMode(5,OUTPUT); // LED VOLUME DW   // D5  OK
  pinMode(6,OUTPUT); // LED AUX1        // D6  OK
  pinMode(7,OUTPUT); // LED AUX2        // D7  OK
  pinMode(8,OUTPUT); // LED ST_BY       // D8
  pinMode(9,OUTPUT); // LED FRONT_BLUE  // D10  OK
  pinMode(10,OUTPUT); // LED REAR_RED   // D9 OK
  pinMode(11,OUTPUT); // LED CEN_BLUE   // D13 OK
  //    IR remote                       // D12 OK
  pinMode(13,OUTPUT); // LED SUB_RED    // D11 OK
  if(EEPROM.read(100)!=0){for(int i=0;i<101;i++){EEPROM.update(i,0);}}// очистка памяти при первом включении 
  vol = EEPROM.read(0);treb = EEPROM.read(1);bass = EEPROM.read(2);in = EEPROM.read(3);l_r = EEPROM.read(4);
  front = EEPROM.read(5);rear = EEPROM.read(6);sub = EEPROM.read(7);cc = EEPROM.read(8);out = EEPROM.read(9);
 
  //if(in==3){digitalWrite(6,LOW);digitalWrite(7,LOW);} // LED AUX1 ON AUX2 ON 
  //if(in==0){digitalWrite(6,LOW);digitalWrite(7,HIGH);} // LED AUX1 ON AUX2 OFF 
  //if(in==1){digitalWrite(6,HIGH);digitalWrite(7,LOW);} // LED AUX1 OFF AUX2 ON 
  //digitalWrite(4,HIGH);digitalWrite(5,HIGH); // LED VOLUME
  //if(out=0){vol_sound=vol;digitalWrite(0,LOW);}else{vol_sound=99;digitalWrite(0,HIGH);}// out 5.1 2.1
  
  if(out==0){vol_sound=vol;digitalWrite(0,HIGH);digitalWrite(1,LOW);}
  if(out==1){vol_sound=99;digitalWrite(0,LOW);digitalWrite(1,HIGH);}
  
  powers=1;digitalWrite(8,HIGH);vol_old=vol;vol=99;vol_sound=99;mute=1;audio();cl();
}
 
void loop(){
  //// IR ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  if ( irrecv.decode( &ir )) {Serial.print("0x");Serial.println( ir.value,HEX);irrecv.resume();times=millis();w=1;}// IR приемник - чтение, в мониторе порта отображаются коды кнопок
  if(ir.value==0){gr1=0;gr2=0;  q1=0;q2=0; q3=0;q4=0;  q5=0;q6=0;}// запрет нажатий не активных кнопок пульта
  if(blok==0){
  if(powers==0){
    if(out==0){vol_sound=vol;digitalWrite(0,HIGH);digitalWrite(1,LOW);}
    if(out==1){vol_sound=99;digitalWrite(0,LOW);digitalWrite(1,HIGH);}

/// IR VOLUME
  if(mute==0){
  if(ir.value==VOL_UP){q1=1;q2=0;gr1=1;gr2=0;vol--;fun_vol();digitalWrite(4,LOW);w=1;times=millis();vol5_1();audio();cl();} 
  if(ir.value==VOL_DW){q1=0;q2=1;gr1=0;gr2=1;vol++;fun_vol();digitalWrite(5,LOW);w=1;times=millis();vol5_1();audio();cl();}  
  if(ir.value==0xFFFFFFFF && gr1==1 && q1==1){vol--;gr2=0;fun_vol();digitalWrite(4,LOW);w=1;times=millis();vol5_1();audio();cl();}
  if(ir.value==0xFFFFFFFF && gr2==1 && q2==1){vol++;gr1=0;fun_vol();digitalWrite(5,LOW);w=1;times=millis();vol5_1();audio();cl();}
  }
/// IR TREBLE
  if(ir.value==TREB_UP){q3=1;q4=0;gr1=1;gr2=0;cl();treb++;fun_treb();w=1;times=millis();audio();}
  if(ir.value==TREB_DW){q3=0;q4=1;gr1=0;gr2=1;cl();treb--;fun_treb();w=1;times=millis();audio();}
  if(ir.value==0xFFFFFFFF && gr1==1 && q3==1){gr2=0;cl();treb++;fun_treb();w=1;times=millis();audio();}
  if(ir.value==0xFFFFFFFF && gr2==1 && q4==1){gr1=0;cl();treb--;fun_treb();w=1;times=millis();audio();}
/// IR BASS
  if(ir.value==BASS_UP){q5=1;q6=0;gr1=1;gr2=0;cl();bass++;fun_bass();w=1;times=millis();audio();}
  if(ir.value==BASS_DW){q5=0;q6=1;gr1=0;gr2=1;cl();bass--;fun_bass();w=1;times=millis();audio();}
  if(ir.value==0xFFFFFFFF && gr1==1 && q5==1){gr2=0;cl();bass++;fun_bass();w=1;times=millis();audio();}
  if(ir.value==0xFFFFFFFF && gr2==1 && q6==1){gr1=0;cl();bass--;fun_bass();w=1;times=millis();audio();}  
/// IR AUX
  if(ir.value==AUX1){in=0;l_r=0;cl();digitalWrite(6,LOW);digitalWrite(7,HIGH);w=1;times=millis();audio();delay(200);}// LED AUX1 ON AUX2 OFF 
  if(ir.value==AUX2){in=1;l_r=0;cl();digitalWrite(6,HIGH);digitalWrite(7,LOW);w=1;times=millis();audio();delay(200);}// LED AUX1 OFF AUX2 ON 
/// IR MUTE
  if(ir.value==MUTE && mute==0){vol_old=vol;vol=99;vol_sound=99;mute=1;cl();vol5_1();audio();delay(200);}
  if(ir.value==MUTE && mute==1){vol=vol_old;vol_sound=vol_old;mute=0;cl();vol5_1();audio();delay(200);}
/// IR FRONT  
  if(ir.value==FRONT_UP){front++;cl();fun_front();w=1;times=millis();audio();digitalWrite(10,LOW);}
  if(ir.value==FRONT_DW){front--;cl();fun_front();w=1;times=millis();audio();digitalWrite(10,LOW);}  
/// IR REAR  
  if(ir.value==REAR_UP){rear++;cl();fun_rear();w=1;times=millis();audio();digitalWrite(9,LOW);}
  if(ir.value==REAR_DW){rear--;cl();fun_rear();w=1;times=millis();audio();digitalWrite(9,LOW);}    
/// IR SUB  
  if(ir.value==SUB_UP){sub++;cl();fun_sub();w=1;times=millis();audio();digitalWrite(11,LOW);}
  if(ir.value==SUB_DW){sub--;cl();fun_sub();w=1;times=millis();audio();digitalWrite(11,LOW);}  
/// IR CEN
  if(ir.value==CEN_UP){cc++;cl();fun_cc();w=1;times=millis();audio();digitalWrite(13,LOW);}
  if(ir.value==CEN_DW){cc--;cl();fun_cc();w=1;times=millis();audio();digitalWrite(13,LOW);}    
/// IR CH5_1 CH2_1
   if(ir.value==CH5_1){out=0;cl();w=1;times=millis();vol_sound=vol;audio();digitalWrite(0,HIGH);digitalWrite(1,LOW);delay(200);}   /// LED 5.1CH ON STEREO OFF
   if(ir.value==CH2_1){out=1;cl();w=1;times=millis();vol_sound=99;audio();digitalWrite(0,LOW);digitalWrite(1,HIGH);delay(200);}    /// LED 5.1CH OFF STEREO ON
/// IR DVD = 6IN
   if(ir.value==DVD){in=3;l_r=1;cl();digitalWrite(6,LOW);digitalWrite(7,LOW);w=1;times=millis();audio();delay(200);} // LED AUX1 ON AUX2 ON 
/// IR STEREO
   if(ir.value==STEREO){in=0;l_r=0;cl();digitalWrite(6,LOW);digitalWrite(7,HIGH);w=1;times=millis();audio();delay(200);} // LED AUX1 ON AUX2 OFF 
  }// power=0
 
///  POWER
   if(ir.value==POWER && powers==1){
   powers=0;cl();vol=vol_old;
   if(in==0){digitalWrite(6,LOW);digitalWrite(7,HIGH);}if(in==1){digitalWrite(6,HIGH);digitalWrite(7,LOW);}

   if(out==0){vol_sound=vol;digitalWrite(0,HIGH);digitalWrite(1,LOW);}
   if(out==1){vol_sound=99;digitalWrite(0,LOW);digitalWrite(1,HIGH);}
   if(l_r==1){digitalWrite(6,LOW);digitalWrite(7,LOW);}
   if(l_r==0&&in==0){digitalWrite(6,LOW);digitalWrite(7,HIGH);}
   if(l_r==0&&in==1){digitalWrite(6,HIGH);digitalWrite(7,LOW);}
   
   digitalWrite(8,LOW);mute=0;cl();audio();delay(200);} // ON 
   
   if(ir.value==POWER && powers==0){w=0;powers=1;digitalWrite(8,HIGH);vol_old=vol;vol=99;vol_sound=99;mute=1;cl();vol5_1();audio();cl();delay(200);} // OFF
  }// blok
////////////////////////// BUTTON /////////////////////////////////////////////////////////  
  if(blok==0){
  if(powers==0){

  if(out==0){vol_sound=vol;digitalWrite(0,HIGH);digitalWrite(1,LOW);}
  if(out==1){vol_sound=99;digitalWrite(0,LOW);digitalWrite(1,HIGH);}

  //// VOLUME
  if(analogRead(A0)<900){vol--;fun_vol();digitalWrite(4,LOW);w=1;times=millis();vol5_1();audio();cl();}
  if(analogRead(A1)<900){vol++;fun_vol();digitalWrite(5,LOW);w=1;times=millis();vol5_1();audio();cl();}
  /// AUX
  if(analogRead(A4)<900 && in==0){in=1;l_r=0;digitalWrite(6,HIGH);digitalWrite(7,LOW);w=1;times=millis();audio();cl();delay(200);}// LED AUX1 OFF AUX2 ON 
  if(analogRead(A4)<900 && in==1){in=0;l_r=0;digitalWrite(6,LOW);digitalWrite(7,HIGH);w=1;times=millis();audio();cl();delay(200);}// LED AUX1 ON AUX2 OFF 
  /// CH5_1 выход 5,1
  if(analogRead(A2)<900 ){out=0;cl();w=1;times=millis();vol_sound=vol;audio();digitalWrite(0,HIGH);digitalWrite(1,LOW);delay(200);}  /// LED 5.1CH ON STEREO OFF
  /// STEREO выход 2,1
  if(analogRead(A3)<900 ){out=1;cl();w=1;times=millis();vol_sound=99;audio();digitalWrite(0,LOW);digitalWrite(1,HIGH);delay(200);}  /// LED 5.1CH OFF STEREO ON
  /// MODE
  if(analogRead(A5)<900 && l_r==0){in=3;l_r=1;cl();digitalWrite(6,LOW);digitalWrite(7,LOW);w=1;times=millis();audio();delay(200);} // LED AUX1 ON AUX2 ON 
  if(analogRead(A5)<900 && l_r==1){in=0;l_r=0;cl();digitalWrite(6,LOW);digitalWrite(7,HIGH);w=1;times=millis();audio();delay(200);} // LED AUX1 ON AUX2 OFF 
 
  }// power==0
 
///  POWER
   if(analogRead(A6)<900 && powers==1){
   powers=0;cl();vol=vol_old;
   if(in==0){digitalWrite(6,LOW);digitalWrite(7,HIGH);}if(in==1){digitalWrite(6,HIGH);digitalWrite(7,LOW);}
   
   if(out==0){vol_sound=vol;digitalWrite(0,HIGH);digitalWrite(1,LOW);}
   if(out==1){vol_sound=99;digitalWrite(0,LOW);digitalWrite(1,HIGH);}
   if(l_r==1){digitalWrite(6,LOW);digitalWrite(7,LOW);}
   if(l_r==0&&in==0){digitalWrite(6,LOW);digitalWrite(7,HIGH);}
   if(l_r==0&&in==1){digitalWrite(6,HIGH);digitalWrite(7,LOW);}

   digitalWrite(8,LOW);mute=0;cl();audio();delay(200);} // ON 
 
   if(analogRead(A6)<900 && powers==0){w=0;powers=1;digitalWrite(8,HIGH);vol_old=vol;vol=99;vol_sound=99;mute=1;cl();vol5_1();audio();cl();delay(200);} // OFF
  }// blok
  //// EEPROM //////////////////////////////////////////////////////////////////////////////
  if(millis()-times>5000 && w==1 && powers == 0){EEPROM.update(0,vol);EEPROM.update(1,treb);EEPROM.update(2,bass);EEPROM.update(3,in);EEPROM.update(4,l_r);
                                  EEPROM.update(5,front);EEPROM.update(6,rear);EEPROM.update(7,sub);EEPROM.update(8,cc);EEPROM.update(9,out);
  w=0;}
 
  delay(50);
  if(blok==0){digitalWrite(4,HIGH);digitalWrite(5,HIGH);}
  digitalWrite(9,HIGH);digitalWrite(10,HIGH);digitalWrite(13,HIGH);digitalWrite(11,HIGH);
 
  if(powers==1){digitalWrite(6,HIGH);digitalWrite(7,HIGH);digitalWrite(9,HIGH);digitalWrite(10,HIGH);
  digitalWrite(13,HIGH);digitalWrite(11,HIGH);digitalWrite(0,HIGH);digitalWrite(1,HIGH);}
 
  /// security
  if(analogRead(A0)<900 && analogRead(A1)<900 && blok==0){blok=1;digitalWrite(4,LOW);digitalWrite(5,LOW);cl();}
  if(analogRead(A0)<900 && analogRead(A1)<900 && blok==1){bbb++;cl();}
  if((analogRead(A0)>900 || analogRead(A1)>900) && blok==1){bbb=0;}
  if(bbb>20){blok=0;bbb=0;digitalWrite(4,HIGH);digitalWrite(5,HIGH);delay(3000);}
}
void vol5_1(){if(out==0){vol_sound=vol;}if(out==1){vol_sound=99;}}
void cl(){delay(100);ir.value=0;}
void fun_vol(){if(vol>99){vol=99;}if(vol<0){vol=0;}}
void fun_treb(){if(treb>15){treb=15;}if(treb<0){treb=0;}}
void fun_bass(){if(bass>15){bass=15;}if(bass<0){bass=0;}}
void fun_front(){if(front>7){front=7;}if(front<0){front=0;}}
void fun_rear(){if(rear>7){rear=7;}if(rear<0){rear=0;}}
void fun_cc(){if(cc>7){cc=7;}if(cc<0){cc=0;}}
void fun_sub(){if(sub>7){sub=7;}if(sub<0){sub=0;}}
 
void audio(){
  Slot1(in,3,0,l_r,bass,treb,0); 
    // input selector  1...4 === int 0...3, in4 === multi in
    //REC-Output Gain Control int 0...6 dB === int 0...3
    //ADC Input ATT 0...-6 dB === int 0...3
    //L/R Input 0 === IN1...3, 1 === IN4 MULTI
    //bass int 0 === +14dB int 8 === 0dB int 15 === -14dB
    //treble int 0 === +14dB int 8 === 0dB int 15 === -14dB
    //Input Gain 0...14 dB === int 0...7
  Slot2(front,vol,front,vol); // gain0, volume0, gain1, volume1
  Slot3(cc,vol_sound,sub,vol); // gain2, volume2, gain3, volume3
  Slot4(rear,vol_sound,rear,vol_sound); // gain4, volume4, gain5, volume5
  // gain 0...14 dB === int 0...7
  // volume 0...-99 dB === int 0...100
}