1

Тема: NJW1157

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

http://forum.rcl-radio.ru/uploads/images/2021/06/c72c04a64971a784244e152e8024f050.png

http://forum.rcl-radio.ru/uploads/images/2021/06/037f2d1006f17dfea451932fe9e29dda.png

http://forum.rcl-radio.ru/uploads/images/2021/06/eaa7dfe520b36bf47caa4534910a1389.png


#define REQ  2 // LATCH pin 79
#define SCK  3 // CLOCK pin 78
#define DATA 4 // DATA  pin 77

void setup() {
  pinMode(REQ,OUTPUT);
  pinMode(SCK,OUTPUT);
  pinMode(DATA,OUTPUT);

}

void loop() {
  Write(0b00000101, 0b00000000);// volume 1
  Write(0b00010101, 0b00000000);// volume 2
  Write(0b00100101, 0b00000000);// volume 3
  Write(0b00110101, 0b00000000);// volume 4
  Write(0b01000101, 0b00000000);// volume 5
  Write(0b01010101, 0b00000000);// volume 6
  Write(0b01100101, 0b00000000);// volume 7
  Write(0b01110101, 0b00000000);// volume 8

  Write(0b10000101, 0b00000000);// set1
  Write(0b10010101, 0b00000000);// set2
  Write(0b10100101, 0b00000000);// set3
  Write(0b10110101, 0b00000000);// set4
  Write(0b11000101, 0b00000000);// set5
  

}

void Write(byte reg, byte dout){  // WRITE_REG 
  
  digitalWrite(REQ,LOW);digitalWrite(SCK,HIGH);
     for(int i = 7; i >= 0; i--){
        digitalWrite(DATA, (dout >> i) & 0x01);
        digitalWrite(SCL,LOW);digitalWrite(SCL,HIGH);
        }
     for(int i = 7; i >= 0; i--){
        digitalWrite(DATA, (reg >> i) & 0x01);
        digitalWrite(SCL,LOW); digitalWrite(SCL,HIGH);
        }
        digitalWrite(SCL,HIGH);digitalWrite(REQ,HIGH);  
  }