Code was not Working Please Help

Joined
May 30, 2023
Messages
4
Reaction score
0
I have a processor NJW1153..I decided to make A test Sketch for But the Skech Was not working....I mean When I upload the Sketch Using Arduino Nano there Is no Sound in That Processor how can i solve this problem....



#include<Arduino.h>
#include <Wire.h>
#define njw1153_address
#define REQ 6 // LATCH pin 31
#define SCK 5 // CLOCK pin 30
#define DATA 4 // DATA pin 29

//Sub addresses
#define njw1153_Volume_1 0b00000101
#define njw1153_Volume_2 0b00010101
#define njw1153_Volume_3 0b00100101
#define njw1153_Volume_4 0b00110101
#define njw1153_Volume_5 0b01000101
#define njw1153_Volume_6 0b01010101
#define njw1153_slot1 0b01100101
#define njw1153_slot2 0b01110101
#define njw1153_slot3 0b10000101
#define njw1153_slot4 0b10010101

void setup(){
Serial.begin(9600);
pinMode(REQ,OUTPUT);
pinMode(SCK,OUTPUT);
pinMode(DATA,OUTPUT);
Wire.begin();

}
void loop() {
setVolume_1(100); // 0
setVolume_2(100);
setVolume_3(100);
setVolume_4(100);
setVolume_5(100);
setVolume_6(100);
setSlot1(2,0,0,0);
setSlot2(5, 1);
setSlot3(5);
setSlot4(7,0,0);
//writeWire(char a, char b);
}
//volume
void setVolume_1(int volume_1){
if(volume_1 == 100){
volume_1 = 100 - volume_1;
}
digitalWrite(njw1153_Volume_1,volume_1);
}
void setVolume_2(int volume_2){
if(volume_2 == 100 ){
volume_2 = 100 - volume_2;
}
digitalWrite(njw1153_Volume_2,volume_2);
}
void setVolume_3(int volume_3){
if(volume_3 == 100){
volume_3 = 100 - volume_3;
}
digitalWrite(njw1153_Volume_3,volume_3);
}
void setVolume_4(int volume_4){
if(volume_4 == 100 ){
volume_4 = 100 - volume_4;
}
digitalWrite(njw1153_Volume_4,volume_4);
}
void setVolume_5(int volume_5){
if(volume_5 == 100){
volume_5 = 100 - volume_5;
}
digitalWrite(njw1153_Volume_5,volume_5);
}
void setVolume_6(int volume_6){
if(volume_6 == 100){
volume_6 = 100 - volume_6;
}
digitalWrite(njw1153_Volume_6,volume_6);
}

void setSlot1(int in_gain, int vol_out_gain,int Bsw,int Ssw){
switch(in_gain){
case 0: in_gain = 0b000;break;
case 1: in_gain = 0b001;break;
case 2: in_gain = 0b010;break;
case 3: in_gain = 0b011;break;
case 4: in_gain = 0b100;break;
}
switch(vol_out_gain){
case 0: vol_out_gain = 0b000;break;
case 1: vol_out_gain = 0b001;break;
case 2: vol_out_gain = 0b010;break;
case 3: vol_out_gain = 0b011;break;
case 5: vol_out_gain = 0b100;break;
case 6: vol_out_gain = 0b101;break;
case 7: vol_out_gain = 0b110;break;
}
switch(Bsw){
case 0: Bsw = 0b0;break;
case 1: Bsw = 0b1;break;
}
switch(Ssw){
case 0: Ssw = 0b0;break;
case 1: Ssw = 0b1;break;
}
digitalWrite(njw1153_slot1, (vol_out_gain, Bsw, Ssw));
}
void setSlot2(int treble, int Tone){
switch(treble){
case 0: treble = 0b10000;break;
case 1: treble = 0b10001;break;
case 3: treble = 0b10010;break;
case 4: treble = 0b10011;break;
case 5: treble = 0b10100;break;
case 6: treble = 0b10101;break;
case 7: treble = 0b10110;break;
case 8: treble = 0b10111;break;
case 9: treble = 0b11001;break;
case 10: treble = 0b11010;break;
case -1: treble= 0b00000;break;
case -2: treble = 0b00001;break;
case -3: treble = 0b00010;break;
case -4: treble= 0b00011;break;
case -5: treble = 0b00100;break;
case -6: treble = 0b00101;break;
case -7: treble = 0b00110;break;
case -8: treble = 0b00111;break;
case -9: treble = 0b01000;break;
case -10: treble = 0b01001;break;
}
switch(Tone){
case 0: Tone = 0b0;break;
case 1: Tone = 0b1;break;
}
digitalWrite(njw1153_slot2, (treble, Tone));
}

void setSlot3( int bass){
switch(bass){
case 0: bass = 0b10000;break;
case 1: bass = 0b10001;break;
case 2: bass = 0b10010;break;
case 3: bass = 0b10011;break;
case 4: bass = 0b10100;break;
case 5: bass = 0b10101;break;
case 6: bass = 0b10110;break;
case 7: bass = 0b10111;break;
case 8: bass = 0b11000;break;
case 9: bass = 0b11001;break;
case 10: bass = 0b11010;break;
case -1: bass = 0b00000;break;
case -2: bass = 0b00001;break;
case -3: bass = 0b00010;break;
case -4: bass = 0b00011;break;
case -5: bass = 0b00100;break;
case -6: bass = 0b00101;break;
case -7: bass = 0b00110;break;
case -8: bass = 0b00111;break;
case -9: bass = 0b01000;break;
case -10: bass= 0b01001;break;

}
digitalWrite(njw1153_slot3, ( bass));
}

void setSlot4(int Input_Sel, int Multi_input, int Rec){
switch (Input_Sel){
case 0: Input_Sel = 0b000;break;
case 1: Input_Sel = 0b001;break;
case 2: Input_Sel = 0b010;break;
case 3: Input_Sel = 0b011;break;
case 4: Input_Sel = 0b100;break;
case 5: Input_Sel = 0b101;break;
case 6: Input_Sel = 0b110;break;
case 7: Input_Sel = 0b111;break;
}
switch(Multi_input){
case 0: Multi_input = 0b00;break;
case 1: Multi_input = 0b01;break;
case 2: Multi_input = 0b10;break;
}
switch(Rec){
case 0: Rec = 0b0;break;
case 1: Rec = 0b1;break;
}
digitalWrite(njw1153_slot4, (Input_Sel, Multi_input, Rec) );
}

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);
}
 
Joined
May 30, 2023
Messages
4
Reaction score
0
NJW1153 Processor Datasheet and Clock Serial Data Image
 

Attachments

  • bc774d71c3d10417b2666cca6a1f117ebc5930f3.png
    bc774d71c3d10417b2666cca6a1f117ebc5930f3.png
    34.7 KB · Views: 4
  • NJW1153.PDF
    296.6 KB · Views: 5

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,529
Members
45,001
Latest member
Kendra00E1

Latest Threads

Top