How to make 5.1 remote kit at home with PT2323 and PT2258
This is my second 5.1 remote kit project. I have included four sections in this project. First one is a pre-amp, the second one is a controller, the third one is a power supply unit and the forth one is power out relay. I drew the all circuits by hand with a CD marker on the copper clad board.
Features
- Power ON/OFF switch
- Mute switch
- Input switch
- USB input (for Stereo Audio player)
- AUX input
- DVD input (5.1-channel)
- Master volume: 0 to 50
- 6-channels volume: -10 to 10
- Surround ON/OFF
- Speaker mode: 5.1/2.1
- All reset
- Remote control
Pre-amp
The pre-amp consists of two ICs. Those are PT2323(SOP) and PT2258(DIP). It has two stereo inputs and one six-channel (5.1-channel) input. Two stereo inputs are USB and AUX. You can connect 5V stereo audio player to the USB input. I have provided the 5v ON/OFF power for this. Six-channel input is DVD.
Controller
I used to atmega328p for the controlling section. It programmed with Arduino UNO. By the end of this post you should be able to copy the code.
Used push buttons for Power ON/OFF, Mute/Unmute and Input selection. Rotary encoder for volume up/down and channel/menu select. Long press the rotary encoder's switch for the menu function. It has two power controller. First one is AMP POWER. This is for Power ON/OFF. Second one is USB POWER. This is for USB input.
You can use Push buttons instead the rotary encoder. But need to use the pull-up resistors. See the circuit as below.
Power supply
Check the power supply circuit carefully. It has two negative supplies. Those are AGND and DGND. It has needed for this project.
Power out
Arduino Code
// 5.1 Surround System // DaacWaves <https://https://daacwaves.blogspot.com> #include <Wire.h> #include <EEPROM.h> #include <LiquidCrystal.h> #include <IRremote.h> #define PT2323_address 0b1001010 #define PT2258_address 0b1000100 #define btn_delay 300 #define sw01 9 // SW #define sw02 11 // DT #define sw03 10 // CLK #define sw04 A0 // Input #define sw05 A1 // Mute #define sw06 A2 // Power #define sw_power 13 // Out #define sw_in_1 12 // Out // IR HEX code #define ir_power 0x807F827D // IR power ON/OFF #define ir_mute 0x807F42BD // IR mute #define ir_in_1 0x807F629D // IR input MP3 #define ir_in_2 0x807F22DD // IR input AUX #define ir_in_3 0x807F20DF // IR input DVD #define ir_vol_i 0x807F906F // IR vol++ #define ir_vol_d 0x807FA05F // IR vol-- #define ir_fl_i 0x807F40BF // IR fl++ #define ir_fl_d 0x807FC03F // IR fl-- #define ir_fr_i 0x807F00FF // IR fr++ #define ir_fr_d 0x807F807F // IR fr-- #define ir_sl_i 0x807F48B7 // IR sl++ #define ir_sl_d 0x807FC837 // IR sl-- #define ir_sr_i 0x807F08F7 // IR sr++ #define ir_sr_d 0x807F8877 // IR sr-- #define ir_cn_i 0x807F50AF // IR cn++ #define ir_cn_d 0x807F609F // IR cn-- #define ir_sub_i 0x807FD02F // IR sub++ #define ir_sub_d 0x807FE01F // IR sub-- #define ir_sp_mode 0x807F0AF5 // IR speaker mode change #define ir_surr_mode 0x807FA857 // IR surround ON/OFF #define ir_reset 0x807F1AE5 // IR reset IRrecv irrecv(8); decode_results results; byte custom_num[8][8] = { { B00111, B01111, B11111, B11111, B11111, B11111, B11111, B11111 }, { B11111, B11111, B11111, B00000, B00000, B00000, B00000, B00000 }, { B11100, B11110, B11111, B11111, B11111, B11111, B11111, B11111 }, { B11111, B11111, B11111, B11111, B11111, B11111, B01111, B00111 }, { B00000, B00000, B00000, B00000, B00000, B11111, B11111, B11111 }, { B11111, B11111, B11111, B11111, B11111, B11111, B11110, B11100 }, { B11111, B11111, B11111, B00000, B00000, B00000, B11111, B11111 }, { B11111, B11111, B11111, B11111, B11111, B11111, B11111, B11111 } }; const int digit_width = 3; const char custom_num_top[10][digit_width] = { 0, 1, 2, 1, 2, 32, 6, 6, 2, 6, 6, 2, 3, 4, 7, 7, 6, 6, 0, 6, 6, 1, 1, 2, 0, 6, 2, 0, 6, 2}; const char custom_num_bot[10][digit_width] = { 3, 4, 5, 4, 7, 4, 7, 4, 4, 4, 4, 5, 32, 32, 7, 4, 4, 5, 3, 4, 5, 32, 32, 7, 3, 4, 5, 4, 4, 5}; byte arrow_right[8] = {B00000, B10000, B11000, B11100, B11110, B11100, B11000, B10000}; LiquidCrystal lcd(7, 6, 5, 4, 3, 2); // RS,E,D4,D5,D6,D7 unsigned long time; int in, mute, return_d, surr, mix, a, b, x, power, menu, menu_active, ch_mute, speaker_mode, btn_press, long_press, vol_menu, vol_menu_jup, reset; int fl, fr, sl, sr, cn, sub, ir_menu, ir_on, vol_on, mas_vol, fl_vol, fr_vol, sl_vol, sr_vol, cn_vol, sub_vol, pt2258_mute; long btn_timer = 0; long long_press_time = 600; void setup() { Wire.begin(); Serial.begin(9600); irrecv.enableIRIn(); pinMode(sw01, INPUT); // SW pinMode(sw02, INPUT); // DT pinMode(sw03, INPUT); // CLK pinMode(sw04, INPUT); // Input pinMode(sw05, INPUT); // Mute pinMode(sw06, INPUT); // Power pinMode(sw_power, OUTPUT); // Out pinMode(sw_in_1, OUTPUT); // Out digitalWrite(sw_power, LOW); digitalWrite(sw_in_1, HIGH); lcd.begin(16, 2); power = 0; eeprom_read(); start_up(); power_up(); } void loop() { lcd_update(); eeprom_update(); ir_control(); return_delay(); if (menu_active == 0) { custom_num_shape(); } else { custom_shape(); } //power -------------------------------------------------// if (analogRead(sw06) > 900) { power++; if (power > 1) { power = 0; } power_up(); delay(btn_delay); } if (power == 1) { //select input -------------------------------------------------// if (analogRead(sw04) > 900) { in++; set_in(); in_power_sw(); delay(btn_delay); } //select menu -------------------------------------------------// if (digitalRead(sw01) == LOW) { if (btn_press == 0) { btn_press = 1; btn_timer = millis(); } if ((millis() - btn_timer > long_press_time) && (long_press == 0) && (menu_active == 0)) { long_press = 1; menu_active = 1; menu = 1; btn_cl(); lcd.clear(); } else if ((millis() - btn_timer > long_press_time) && (long_press == 0) && (menu_active == 1)) { long_press = 1; menu_active = 0; vol_menu = 0; reset = 0; btn_cl(); lcd.clear(); } } else { if (btn_press == 1) { if (long_press == 1) { long_press = 0; } else { if (menu_active == 1) { menu++; if (menu > 3) { menu = 1; } btn_cl(); lcd.clear(); } else if (menu_active == 0 && speaker_mode == 0) { vol_menu++; if (vol_menu > 6) { vol_menu = 0; } btn_cl(); } else if (menu_active == 0 && speaker_mode == 1) { vol_menu++; if (vol_menu_jup == 0) { if (vol_menu > 2) { vol_menu = 6; vol_menu_jup = 1; } } if (vol_menu_jup == 1) { if (vol_menu > 6) { vol_menu = 0; vol_menu_jup = 0; } } btn_cl(); } } btn_press = 0; } } //mute -------------------------------------------------// if (analogRead(sw05) > 900) { mute++; if (mute == 1) { menu_active = 99; } else { menu_active = 0; } set_mute(); delay(btn_delay); lcd.clear(); } } //menu active 0 -------------------------------------------------// if (menu_active == 0) { if (digitalRead(sw02) == LOW) { if (vol_menu == 0) { mas_vol++; } if (vol_menu == 1) { fl_vol++; } if (vol_menu == 2) { fr_vol++; } if (vol_menu == 3) { sl_vol++; } if (vol_menu == 4) { sr_vol++; } if (vol_menu == 5) { cn_vol++; } if (vol_menu == 6) { sub_vol++; } set_mas_vol(); set_fl(); set_fr(); set_sl(); set_sr(); set_cn(); set_sub(); btn_cl(); } if (digitalRead(sw03) == LOW) { if (vol_menu == 0) { mas_vol--; } if (vol_menu == 1) { fl_vol--; } if (vol_menu == 2) { fr_vol--; } if (vol_menu == 3) { sl_vol--; } if (vol_menu == 4) { sr_vol--; } if (vol_menu == 5) { cn_vol--; } if (vol_menu == 6) { sub_vol--; } set_mas_vol(); set_fl(); set_fr(); set_sl(); set_sr(); set_cn(); set_sub(); btn_cl(); } } //menu active 1 -------------------------------------------------// if (menu_active == 1) { if (menu == 1) { if (digitalRead(sw02) == LOW) { surr++; set_surr(); btn_cl(); } } if (menu == 2) { if (digitalRead(sw02) == LOW) { speaker_mode++; if (speaker_mode == 1) { vol_menu_jup = 0; } set_speaker_mode(); btn_cl(); } } if (menu == 3) { if (digitalRead(sw02) == LOW) { reset++; set_reset(); btn_cl(); } } } } //eeprom -----------------------------------------------------// void eeprom_update() { EEPROM.update(0, in); EEPROM.update(1, mas_vol); EEPROM.update(2, fl_vol + 10); EEPROM.update(3, fr_vol + 10); EEPROM.update(4, sl_vol + 10); EEPROM.update(5, sr_vol + 10); EEPROM.update(6, cn_vol + 10); EEPROM.update(7, sub_vol + 10); EEPROM.update(8, surr); EEPROM.update(9, speaker_mode); } void eeprom_read() { in = EEPROM.read(0); mas_vol = EEPROM.read(1); fl_vol = EEPROM.read(2) - 10; fr_vol = EEPROM.read(3) - 10; sl_vol = EEPROM.read(4) - 10; sr_vol = EEPROM.read(5) - 10; cn_vol = EEPROM.read(6) - 10; sub_vol = EEPROM.read(7) - 10; surr = EEPROM.read(8); speaker_mode = EEPROM.read(9); } void btn_cl() { delay(btn_delay); time = millis(); return_d = 1; } void ir_cl() { time = millis(); return_d = 1; } void return_delay() { if (millis() - time > 5000 && return_d == 1 && mute == 0 && menu_active != 0) { menu_active = 0; vol_menu = 0; reset = 0; return_d = 0; lcd.clear(); } else if (millis() - time > 5000 && return_d == 1 && mute == 0 && menu_active == 0) { vol_menu = 0; return_d = 0; } } //power up -----------------------------------------------------// void power_up() { if (power == 1) { lcd.clear(); delay(500); lcd.setCursor(0, 1); lcd.print(" LOADING... "); delay(1000); lcd.clear(); mute = 0; set_mute(); vol_menu = 0; menu_active = 0; delay(300); in_power_sw(); ir_on = 1; vol_on = 0; vol_menu_jup = 0; digitalWrite(sw_power, HIGH); } else { digitalWrite(sw_power, LOW); mute = 1; set_mute(); delay(100); in_power_sw(); menu_active = 100; ir_on = 0; } } void in_power_sw() { if (power == 1) { if (in == 0) { digitalWrite(sw_in_1, LOW); } else { digitalWrite(sw_in_1, HIGH); } } else { digitalWrite(sw_in_1, HIGH); } } void start_up() { mute = 1; set_mute(); delay(500); lcd.setCursor(0, 0); lcd.print(" Ui Tech "); delay(500); lcd.setCursor(0, 1); lcd.print(" 5.1 SYSTEM "); delay(1000); lcd.clear(); delay(300); lcd.setCursor(0, 1); lcd.print(" LOADING... "); delay(1500); lcd.clear(); delay(300); set_in(); set_surr(); set_mix(); pt2258(); set_fl(); set_fr(); set_sl(); set_sr(); set_cn(); set_sub(); } //IR control --------------------------------------------------------------------------------// void ir_control() { if ( irrecv.decode( &results )) { switch (results.value) { //power -------------------------------------------------// case ir_power: power++; if (power > 1) { power = 0; } power_up(); break; } if (ir_on == 1) { switch (results.value) { //mute -------------------------------------------------// case ir_mute: mute++; if (mute == 1) { menu_active = 99; } else { menu_active = 0; } set_mute(); lcd.clear(); break; //select input -------------------------------------------------// case ir_in_1: in = 0; set_in(); in_power_sw(); ir_cl(); break; case ir_in_2: in = 1; set_in(); in_power_sw(); ir_cl(); break; case ir_in_3: in = 2; set_in(); in_power_sw(); ir_cl(); break; } } if (ir_on == 1 && vol_on == 0 && menu_active == 0) { switch (results.value) { //VOL -------------------------------------------------// case ir_vol_i: if (speaker_mode == 0 || speaker_mode == 1) { mas_vol++; vol_menu = 0; } break; case ir_vol_d: if (speaker_mode == 0 || speaker_mode == 1) { mas_vol--; vol_menu = 0; } break; //FL -------------------------------------------------// case ir_fl_i: if (speaker_mode == 0 || speaker_mode == 1) { fl_vol++; vol_menu = 1; } break; case ir_fl_d: if (speaker_mode == 0 || speaker_mode == 1) { fl_vol--; vol_menu = 1; } break; //FR -------------------------------------------------// case ir_fr_i: if (speaker_mode == 0 || speaker_mode == 1) { fr_vol++; vol_menu = 2; } break; case ir_fr_d: if (speaker_mode == 0 || speaker_mode == 1) { fr_vol--; vol_menu = 2; } break; //SL -------------------------------------------------// case ir_sl_i: if (speaker_mode == 0) { sl_vol++; vol_menu = 3; } break; case ir_sl_d: if (speaker_mode == 0) { sl_vol--; vol_menu = 3; } break; //SR -------------------------------------------------// case ir_sr_i: if (speaker_mode == 0) { sr_vol++; vol_menu = 4; } break; case ir_sr_d: if (speaker_mode == 0) { sr_vol--; vol_menu = 4; } break; //CN -------------------------------------------------// case ir_cn_i: if (speaker_mode == 0) { cn_vol++; vol_menu = 5; } break; case ir_cn_d: if (speaker_mode == 0) { cn_vol--; vol_menu = 5; } break; //SUB -------------------------------------------------// case ir_sub_i: if (speaker_mode == 0 || speaker_mode == 1) { sub_vol++; vol_menu = 6; } break; case ir_sub_d: if (speaker_mode == 0 || speaker_mode == 1) { sub_vol--; vol_menu = 6; } break; //speaker mode -------------------------------------------------// case ir_sp_mode: speaker_mode++; vol_menu = 0; if (speaker_mode == 1) { vol_menu_jup = 0; } break; //surround -------------------------------------------------// case ir_surr_mode: surr++; vol_menu = 0; break; // -------------------------------------------------// case ir_reset: reset++; vol_menu = 0; break; } set_mas_vol(); set_fl(); set_fr(); set_sl(); set_sr(); set_cn(); set_sub(); set_speaker_mode(); set_surr(); set_reset(); ir_cl(); } irrecv.resume(); } } //custom shape --------------------------------------------------------------------------------// void custom_num_shape() { for (int i = 0; i < 8; i++) lcd.createChar(i, custom_num[i]); } void custom_shape() { lcd.createChar(1, arrow_right); } //lcd ---------------------------------------------------------// void lcd_update() { int c; switch (menu_active) { case 0: //input -------------------------------------------------// lcd.setCursor(0, 0); if (in == 0) { lcd.print("USB"); } if (in == 1) { lcd.print("AUX"); } if (in == 2) { lcd.print("DVD"); } //speaker mode ------------------------------------------// lcd.setCursor(4, 0); if (speaker_mode == 0) { lcd.print("5.1"); } if (speaker_mode == 1) { lcd.print("2.1"); } //vol ----------------------------------------------// switch (vol_menu) { case 0: lcd.setCursor(0, 1); // (" "); lcd.print("MAS-VOL"); c = mas_vol - 19; break; case 1: lcd.setCursor(0, 1); // (" "); lcd.print("FL-VOL "); c = fl_vol; break; case 2: lcd.setCursor(0, 1); // (" "); lcd.print("FR-VOL "); c = fr_vol; break; case 3: lcd.setCursor(0, 1); // (" "); lcd.print("SL-VOL "); c = sl_vol; break; case 4: lcd.setCursor(0, 1); // (" "); lcd.print("SR-VOL "); c = sr_vol; break; case 5: lcd.setCursor(0, 1); // (" "); lcd.print("CN-VOL "); c = cn_vol; break; case 6: lcd.setCursor(0, 1); // (" "); lcd.print("SUB-VOL"); c = sub_vol; break; } break; case 1: switch (menu) { case 1: lcd.setCursor(0, 0); lcd.print("Surround"); lcd.setCursor(1, 1); lcd.print("ON"); lcd.setCursor(6, 1); lcd.print("OFF"); if (surr == 0) { lcd.setCursor(0, 1); lcd.write(1); lcd.setCursor(5, 1); lcd.print(" "); } if (surr == 1) { lcd.setCursor(0, 1); lcd.print(" "); lcd.setCursor(5, 1); lcd.write(1); } break; case 2: lcd.setCursor(0, 0); lcd.print("Speaker Mode"); lcd.setCursor(1, 1); lcd.print("5.1"); lcd.setCursor(6, 1); lcd.print("2.1"); if (speaker_mode == 0) { lcd.setCursor(0, 1); lcd.write(1); lcd.setCursor(5, 1); lcd.print(" "); } if (speaker_mode == 1) { lcd.setCursor(0, 1); lcd.print(" "); lcd.setCursor(5, 1); lcd.write(1); } break; case 3: lcd.setCursor(0, 0); lcd.print("All Reset"); lcd.setCursor(1, 1); lcd.print("Reset"); if (reset == 1) { lcd.setCursor(0, 1); lcd.write(1); } break; } break; case 99: lcd.setCursor(0, 0); lcd.print(" "); lcd.setCursor(0, 1); lcd.print(" MUTE "); break; case 100: lcd.setCursor(0, 0); lcd.print(" "); lcd.setCursor(0, 1); lcd.print(" STANDBY "); break; } if (menu_active == 0) { int y; if (c < 0) { lcd.setCursor(8, 1); lcd.print("-"); y = 10 - (c + 10); } else if (c == -10) { lcd.setCursor(8, 1); lcd.print("-"); y = 10; } else { lcd.setCursor(8, 1); lcd.print(" "); y = c; } a = y / 10; b = y - a * 10; lcd.setCursor(9, 0); for (int i = 0; i < digit_width; i++) lcd.print(custom_num_top[a][i]); lcd.setCursor(9, 1); for (int i = 0; i < digit_width; i++) lcd.print(custom_num_bot[a][i]); lcd.setCursor(13, 0); for (int i = 0; i < digit_width; i++) lcd.print(custom_num_top[b][i]); lcd.setCursor(13, 1); for (int i = 0; i < digit_width; i++) lcd.print(custom_num_bot[b][i]); } } //all reset --------------------------------------------------------------------------------// void set_reset() { if (reset == 1) { in = 0; mas_vol = 44; fl_vol = 0; fr_vol = 0; sl_vol = 0; sr_vol = 0; cn_vol = 0; sub_vol = 0; speaker_mode = 0; surr = 0; vol_menu = 0; menu_active = 0; reset = 0; lcd.clear(); } set_in(); set_fl(); set_fr(); set_sl(); set_sr(); set_cn(); set_sub(); set_speaker_mode(); set_surr(); in_power_sw(); } //speaker mode --------------------------------------------------------------------------------// void set_speaker_mode() { if (speaker_mode > 1) { speaker_mode = 0; } if (speaker_mode < 0) { speaker_mode = 1; } switch (speaker_mode) { case 0: // 5.1 mode ch_mute = 0; break; case 1: // 2.1 mode ch_mute = 1; break; } set_sl(); set_sr(); set_cn(); } //pt2323 settings -----------------------------------------------------// void set_in() { if (in > 2) { in = 0; } switch (in) { case 0: a = 0b11001011; break; // 1 input case 1: a = 0b11001010; break; // 2 input // case 2: a = 0b11001001; break; // 3 input // case 3: a = 0b11001000; break; // 4 input case 2: a = 0b11000111; break; // 6 CH input } pt2323_send(a); } void set_surr() { if (surr > 1) { surr = 0; } if (surr < 0) { surr = 1; } switch (surr) { case 0: a = 0b11010000; break; // Surround ON case 1: a = 0b11010001; break; // Surround OFF } pt2323_send(a); } void set_mix() { if (mix > 1) { mix = 0; } switch (mix) { case 0: a = 0b10010000; break; // 0dB setup case 1: a = 0b10010001; break; // +6dB setup } pt2323_send(a); } void set_mute() { if (mute > 1) { mute = 0; } if (mute == 1) { vol_on = 1; } else { vol_on = 0; } switch (mute) { case 0: a = 0b11111110; break; // All CH mute disabled case 1: a = 0b11111111; break; // All CH mute } pt2323_send(a); } //pt2258 settings -----------------------------------------------------// void set_mas_vol() { if (mas_vol > 69) { mas_vol = 69; } if (mas_vol < 19) { mas_vol = 19; } if (mas_vol == 19) { pt2258_mute = 1; } else { pt2258_mute = 0; } set_pt2258_mute(); } void set_fl() { if (fl_vol > 10) { fl_vol = 10; } if (fl_vol < -10) { fl_vol = -10; } fl = mas_vol + fl_vol; int c = 79 - fl; a = c / 10; b = c - a * 10; pt2258_send(0b10100000 + a, 0b10110000 + b); // CH6 } void set_fr() { if (fr_vol > 10) { fr_vol = 10; } if (fr_vol < -10) { fr_vol = -10; } fr = mas_vol + fr_vol; int c = 79 - fr; a = c / 10; b = c - a * 10; pt2258_send(0b01100000 + a, 0b01110000 + b); // CH5 } void set_sl() { if (sl_vol > 10) { sl_vol = 10; } if (sl_vol < -10) { sl_vol = -10; } sl = mas_vol + sl_vol; int c = 79 - sl; a = c / 10; b = c - a * 10; pt2258_send(0b01000000 + a, 0b01010000 + b); // CH2 switch (ch_mute) { case 0: x = 0b11111000; break; // SL mute disabled case 1: x = 0b11111001; break; // SL mute } pt2323_send(x); } void set_sr() { if (sr_vol > 10) { sr_vol = 10; } if (sr_vol < -10) { sr_vol = -10; } sr = mas_vol + sr_vol; int c = 79 - sr; a = c / 10; b = c - a * 10; pt2258_send(0b10000000 + a, 0b10010000 + b); // CH1 switch (ch_mute) { case 0: x = 0b11111010; break; // SR mute disabled case 1: x = 0b11111011; break; // SR mute } pt2323_send(x); } void set_cn() { if (cn_vol > 10) { cn_vol = 10; } if (cn_vol < -10) { cn_vol = -10; } cn = mas_vol + cn_vol; int c = 79 - cn; a = c / 10; b = c - a * 10; pt2258_send(0b00100000 + a, 0b00110000 + b); // CH4 switch (ch_mute) { case 0: x = 0b11110100; break; // CN mute disabled case 1: x = 0b11110101; break; // CN mute } pt2323_send(x); } void set_sub() { if (sub_vol > 10) { sub_vol = 10; } if (sub_vol < -10) { sub_vol = -10; } sub = mas_vol + sub_vol; int c = 79 - sub; a = c / 10; b = c - a * 10; pt2258_send(0b00000000 + a, 0b00010000 + b); // CH3 } void set_pt2258_mute() { Wire.beginTransmission(PT2258_address); switch (pt2258_mute) { case 0: Wire.write (0b11111000);; break; // mute disabled case 1: Wire.write (0b11111001);; break; // mute } Wire.endTransmission(); } //pt2323 & pt2258 send -----------------------------------------------------// void pt2323_send(char c) { Wire.beginTransmission(PT2323_address); Wire.write (c); Wire.endTransmission(); } void pt2258() { Wire.beginTransmission(PT2258_address); Wire.write (0b11000000); Wire.endTransmission(); } void pt2258_send(char c, char d) { Wire.beginTransmission(PT2258_address); Wire.write (c); Wire.write (d); Wire.endTransmission(); } //end code