i make a code for testing...when i upload this code i am not getting any sounds.....whats the solution.....its emer
can anyone make test code for njw1153
NJW1153_NewJapanRadio.pdf (337.7 KB)
i want code for njw1153 using arduino anyone can help me...please i want your help guys...
In future please take the time to pick the appropriate category for your topics.
It will help us help you.
There is an about the category at the top of each category.
Haven't taken a look at the download, but have tried an example?
i make this test code but i am not getting any sounds..i think there is an error in my code.
#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);
}
can you check my code
In the future please help us help you by using code tags to post code.
Here is your code in code tags:
#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);
}
can you make a working test code
Nope, it will take to long to reverse engineer your code to be able to take A SWAG at your circuit. Post an annotated schematic, not a frizzy as there are way to many connections to follow. Also post links to any other hardware devices, check them to be sure they have technical data, not a marketplace add.
Is this a school project? If so what class?
no but i like the processor audio
It is a good part, I believe used in some high end Japan equiment and probably some others.
This is the data format for NJW1153 processor
Your topic was moved to its current location as it is more suitable.
Could you also take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.
Thank you
You use digitalWrite(...)
to send something over the 2wire protocol ????
I assume that your english is limited.
With such sentences you give an impression of beeing selfish and egoistic.
I looked up your other thread.
This is the right sub-forum for your attitude
Whats the Solution of that code
Are you reading the responces? Testing and fixing the code is a much beyond of usual forum help, you would better to ask in a paid help category.
Hi,
Why is it an emergency?
Is this a school/college/university project?
Thanks.. Tom..
university project
Sorry, but your code is just a bunch of lines without much meaning
You obviously have no idea about the basic arduino syntax.
What's this:
digitalWrite(njw1153_slot1, (vol_out_gain, Bsw, Ssw));
The first parameter of the digitalWrite()
function is a pin number. But you call it with
#define njw1153_slot1 0b01100101
The second parameter MUST BE either HIGH or LOW. There is no digitalWrite()
version with three or more parameters.
Lets go further...
This seven lines of code doing absolutely nothing, because in_gain
is not changed.
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;
}
Are you know that, for example, 3 and 0b011
are two representations of the same digit?
The same for this
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;
}
and this...
switch(Multi_input){
case 0: Multi_input = 0b00;break;
case 1: Multi_input = 0b01;break;
case 2: Multi_input = 0b10;break;
}
As a conclusion, I would recommend that you read a couple of beginner books on arduino and programming and start with simpler projects.
i have less to complete this project can you give a working testing code please..