1

Тема: M61531FP

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

// M61531FP 
#define DATA     2
#define CLOCK    3
#define LATCH    4


void setup(){ 
  Serial.begin(9600);
  pinMode(DATA,OUTPUT);pinMode(CLOCK,OUTPUT);pinMode(LATCH,OUTPUT);
  digitalWrite(DATA,LOW);digitalWrite(CLOCK,LOW);digitalWrite(LATCH,LOW);

}
 
void loop(){ 
     //   input_sel, input_att, rec_out1, rec_out2, rec_out3, rec_out4, multi_input, lr_vol_in1, input_gain, ins10, all_ch_out_mute, multi_in_mute, lr_vol_in2
  slot0(  0,         0,         0,        0,        0,        0,        0,           0,          0,          0,     0,               0,             0);
     //   l_vol, r_vol, c_vol
  slot1(  0,     0,     0);
     //   sl_vol, sr_vol, sw_vol
  slot2(  0,      0,      0);
     //   bass, treb, tone_in_att, bypass_tone, tone_block, loud, loud_balance, lr_bupass
  slot3(  0,    0,    0,           0,           0,          0,    0,            0);
  delay(1000);
}

void slot0(int input_sel, int input_att, int rec_out1, int rec_out2, int rec_out3, int rec_out4, int multi_input, int lr_vol_in1, int input_gain, int ins10, int all_ch_out_mute, int multi_in_mute, int lr_vol_in2){
     digitalWrite(LATCH,LOW);
   
  for(int i=3;i>=0; i--){
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, (input_sel >> i) & 1);
     digitalWrite(CLOCK,HIGH);
     }
  for(int i=1;i>=0; i--){
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, (input_att >> i) & 1);
     digitalWrite(CLOCK,HIGH);
     }    
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, rec_out1);
     digitalWrite(CLOCK,HIGH);
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, rec_out2);
     digitalWrite(CLOCK,HIGH);        
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, rec_out3);
     digitalWrite(CLOCK,HIGH);
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, rec_out4);
     digitalWrite(CLOCK,HIGH);
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, multi_input);
     digitalWrite(CLOCK,HIGH); 
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, lr_vol_in1);
     digitalWrite(CLOCK,HIGH); 
  for(int i=1;i>=0; i--){
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, (input_gain >> i) & 1);
     digitalWrite(CLOCK,HIGH);
     }  
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, ins10);
     digitalWrite(CLOCK,HIGH);     
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, all_ch_out_mute);
     digitalWrite(CLOCK,HIGH); 
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, multi_in_mute);
     digitalWrite(CLOCK,HIGH); 
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, lr_vol_in2);
     digitalWrite(CLOCK,HIGH); 
     int stot_add0 = 0b0010;                
  for(int i=3;i>=0; i--){
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, (stot_add0 >> i) & 1);
     digitalWrite(CLOCK,HIGH);
     }                    
     digitalWrite(LATCH,HIGH);
     }

 void slot1(int l_vol, int r_vol, int c_vol){
     digitalWrite(LATCH,LOW);
   
  for(int i=6;i>=0; i--){
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, (l_vol >> i) & 1);
     digitalWrite(CLOCK,HIGH);
     }
  for(int i=6;i>=0; i--){
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, (r_vol >> i) & 1);
     digitalWrite(CLOCK,HIGH);
     }  
  for(int i=6;i>=0; i--){
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, (c_vol >> i) & 1);
     digitalWrite(CLOCK,HIGH);
     }          

     int stot_add1 = 0b000;                
  for(int i=2;i>=0; i--){
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, (stot_add1 >> i) & 1);
     digitalWrite(CLOCK,HIGH);
     }                    
     digitalWrite(LATCH,HIGH);
     }    

 void slot2(int sl_vol, int sr_vol, int sw_vol){
     digitalWrite(LATCH,LOW);
   
  for(int i=6;i>=0; i--){
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, (sl_vol >> i) & 1);
     digitalWrite(CLOCK,HIGH);
     }
  for(int i=6;i>=0; i--){
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, (sr_vol >> i) & 1);
     digitalWrite(CLOCK,HIGH);
     }  
  for(int i=6;i>=0; i--){
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, (sw_vol >> i) & 1);
     digitalWrite(CLOCK,HIGH);
     }          

     int stot_add2 = 0b001;                
  for(int i=2;i>=0; i--){
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, (stot_add2 >> i) & 1);
     digitalWrite(CLOCK,HIGH);
     }                    
     digitalWrite(LATCH,HIGH);
     }   

void slot3(int bass, int treb, int tone_in_att, int bypass_tone, int tone_block, int loud, int loud_balance, int lr_bupass){
     digitalWrite(LATCH,LOW);
   
  for(int i=4;i>=0; i--){
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, (bass >> i) & 1);
     digitalWrite(CLOCK,HIGH);
     }
  for(int i=4;i>=0; i--){
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, (treb >> i) & 1);
     digitalWrite(CLOCK,HIGH);
     }  
  for(int i=1;i>=0; i--){
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, (tone_in_att >> i) & 1);
     digitalWrite(CLOCK,HIGH);
     }    
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, bypass_tone);
     digitalWrite(CLOCK,HIGH); 
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, tone_block);
     digitalWrite(CLOCK,HIGH); 
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, loud);
     digitalWrite(CLOCK,HIGH); 
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, loud_balance);
     digitalWrite(CLOCK,HIGH); 
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, lr_bupass);
     digitalWrite(CLOCK,HIGH);                           

     int stot_add3 = 0b00000011;                
  for(int i=7;i>=0; i--){
     digitalWrite(CLOCK,LOW);
     digitalWrite(DATA, (stot_add3 >> i) & 1);
     digitalWrite(CLOCK,HIGH);
     }                    
     digitalWrite(LATCH,HIGH);
     }