Исправлены уровни на управляющих выводах реле
This commit is contained in:
parent
80e15f3a6d
commit
0dfca95615
|
@ -3,16 +3,17 @@
|
|||
// https://alexgyver.ru/lessons/
|
||||
// https://www.hackster.io/mircemk/diy-arduino-vfd-display-20x2-vu-volume-unit-meter-37898f
|
||||
|
||||
#define GAIN 1 // усиление 0...50
|
||||
#define STEP 1 // плавность полос 0...20
|
||||
#define GAIN 5 // усиление 0...50
|
||||
#define STEP 20 // плавность полос 0...20
|
||||
#define RL 1 // RL - горизонт, вертикаль 0...1
|
||||
// Выходы для управления реле (вкл.вкл ЦАП/Блютуз)
|
||||
#define RELAY_POWER_USB 6
|
||||
#define RELAY_POWER_BT 7
|
||||
#define RELAY_POWER_USB 7
|
||||
#define RELAY_POWER_BT 6
|
||||
#define RELAY_POWER_MP3 10
|
||||
#define RELAY_OUT_USB 8
|
||||
#define RELAY_OUT_BT 9
|
||||
#define RELAY_OUT_MP3 11
|
||||
#define RELAY_OUT_BT_LEFT 8
|
||||
#define RELAY_OUT_BT_RIGHT 9
|
||||
#define RELAY_OUT_MP3_LEFT 11
|
||||
#define RELAY_OUT_MP3_RIGHT 12
|
||||
|
||||
// Кнопки
|
||||
#define BTN_MENU 2 // Кнопка меню
|
||||
|
@ -62,9 +63,10 @@ void setup() {
|
|||
pinMode(RELAY_POWER_USB, OUTPUT);
|
||||
pinMode(RELAY_POWER_BT, OUTPUT);
|
||||
pinMode(RELAY_POWER_MP3, OUTPUT);
|
||||
pinMode(RELAY_OUT_USB, OUTPUT);
|
||||
pinMode(RELAY_OUT_BT, OUTPUT);
|
||||
pinMode(RELAY_OUT_MP3, OUTPUT);
|
||||
pinMode(RELAY_OUT_BT_LEFT, OUTPUT);
|
||||
pinMode(RELAY_OUT_BT_RIGHT, OUTPUT);
|
||||
pinMode(RELAY_OUT_MP3_LEFT, OUTPUT);
|
||||
pinMode(RELAY_OUT_MP3_RIGHT, OUTPUT);
|
||||
|
||||
// lcdVuMeter.createChar(5,znak_l);
|
||||
// lcdVuMeter.begin(16, 2);// lcdVuMeter 16X2
|
||||
|
@ -89,14 +91,36 @@ void setup() {
|
|||
}
|
||||
|
||||
w = EEPROM.read(0);
|
||||
if (usb) {
|
||||
digitalWrite(RELAY_POWER_BT,HIGH);
|
||||
digitalWrite(RELAY_POWER_MP3,HIGH);
|
||||
digitalWrite(RELAY_POWER_USB,HIGH);
|
||||
delay(500);
|
||||
digitalWrite(RELAY_OUT_BT_LEFT,HIGH);
|
||||
digitalWrite(RELAY_OUT_BT_RIGHT,HIGH);
|
||||
digitalWrite(RELAY_OUT_MP3_LEFT,HIGH);
|
||||
digitalWrite(RELAY_OUT_MP3_RIGHT,HIGH);
|
||||
}
|
||||
|
||||
|
||||
if (bluetooth) {
|
||||
digitalWrite(RELAY_POWER_USB,HIGH);
|
||||
digitalWrite(RELAY_POWER_MP3,HIGH);
|
||||
delay(500);
|
||||
digitalWrite(RELAY_OUT_MP3_LEFT,HIGH);
|
||||
digitalWrite(RELAY_OUT_MP3_RIGHT,HIGH);
|
||||
delay(1000);
|
||||
digitalWrite(RELAY_OUT_BT_LEFT,LOW);
|
||||
digitalWrite(RELAY_OUT_BT_RIGHT,LOW);
|
||||
digitalWrite(RELAY_POWER_BT,LOW);
|
||||
}
|
||||
if (mp3) {
|
||||
}
|
||||
updateMenu();
|
||||
}
|
||||
|
||||
void vu_metter() {
|
||||
|
||||
if(digitalRead(8)==LOW){w++;www=1;if(w>4){w=0;}delay(200);EEPROM.update(0,w);}
|
||||
// if(digitalRead(8)==LOW){w++;www=1;if(w>4){w=0;}delay(200);EEPROM.update(0,w);}
|
||||
|
||||
if(w==0&&www==1){www=0;
|
||||
byte a1[8] = {0b10101,0b10101,0b10101,0b10101,0b10101,0b10101,0b10101,0b10101};
|
||||
|
@ -168,7 +192,7 @@ i++;if(i<19){u_l0[i]=abs(ull);u_r0[i]=abs(urr);}else{i=1;}
|
|||
}
|
||||
|
||||
String setUSBinput() {
|
||||
return "USB input";
|
||||
return "Input: USB";
|
||||
}
|
||||
|
||||
|
||||
|
@ -236,52 +260,54 @@ void actionUSB() {
|
|||
// lcdService.clear();
|
||||
lcdService.setCursor(2,1);
|
||||
lcdService.print("On ");
|
||||
digitalWrite(RELAY_POWER_BT,LOW);
|
||||
digitalWrite(RELAY_POWER_MP3,LOW);
|
||||
|
||||
digitalWrite(RELAY_OUT_BT,LOW);
|
||||
digitalWrite(RELAY_OUT_MP3,LOW);
|
||||
delay(1000);
|
||||
digitalWrite(RELAY_OUT_USB,HIGH);
|
||||
digitalWrite(RELAY_POWER_BT,HIGH);
|
||||
digitalWrite(RELAY_POWER_MP3,HIGH);
|
||||
digitalWrite(RELAY_POWER_USB,HIGH);
|
||||
delay(500);
|
||||
digitalWrite(RELAY_OUT_BT_LEFT,HIGH);
|
||||
digitalWrite(RELAY_OUT_BT_RIGHT,HIGH);
|
||||
digitalWrite(RELAY_OUT_MP3_LEFT,HIGH);
|
||||
digitalWrite(RELAY_OUT_MP3_RIGHT,HIGH);
|
||||
usb = true;
|
||||
bluetooth = false;
|
||||
mp3 = false;
|
||||
|
||||
delay(1500);
|
||||
// delay(1500);
|
||||
}
|
||||
|
||||
void actionBT() {
|
||||
// lcdService.clear();
|
||||
lcdService.setCursor(2,1);
|
||||
lcdService.print("On ");
|
||||
digitalWrite(RELAY_POWER_USB,LOW);
|
||||
digitalWrite(RELAY_POWER_MP3,LOW);
|
||||
|
||||
digitalWrite(RELAY_OUT_USB,LOW);
|
||||
digitalWrite(RELAY_OUT_MP3,LOW);
|
||||
digitalWrite(RELAY_POWER_USB,HIGH);
|
||||
digitalWrite(RELAY_POWER_MP3,HIGH);
|
||||
delay(500);
|
||||
digitalWrite(RELAY_OUT_MP3_LEFT,HIGH);
|
||||
digitalWrite(RELAY_OUT_MP3_RIGHT,HIGH);
|
||||
delay(1000);
|
||||
digitalWrite(RELAY_OUT_BT,HIGH);
|
||||
digitalWrite(RELAY_POWER_BT,HIGH);
|
||||
digitalWrite(RELAY_OUT_BT_LEFT,LOW);
|
||||
digitalWrite(RELAY_OUT_BT_RIGHT,LOW);
|
||||
digitalWrite(RELAY_POWER_BT,LOW);
|
||||
usb = false;
|
||||
bluetooth = true;
|
||||
mp3 = false;
|
||||
|
||||
delay(1500);
|
||||
// delay(1500);
|
||||
}
|
||||
|
||||
void actionMP3() {
|
||||
// lcdService.clear();
|
||||
lcdService.setCursor(2,1);
|
||||
lcdService.print("On ");
|
||||
digitalWrite(RELAY_POWER_USB,LOW);
|
||||
digitalWrite(RELAY_POWER_BT,LOW);
|
||||
|
||||
digitalWrite(RELAY_OUT_USB,LOW);
|
||||
digitalWrite(RELAY_OUT_BT,LOW);
|
||||
digitalWrite(RELAY_POWER_USB,HIGH);
|
||||
digitalWrite(RELAY_POWER_BT,HIGH);
|
||||
delay(500);
|
||||
digitalWrite(RELAY_OUT_BT_LEFT,HIGH);
|
||||
digitalWrite(RELAY_OUT_BT_RIGHT,HIGH);
|
||||
delay(1000);
|
||||
digitalWrite(RELAY_OUT_MP3,HIGH);
|
||||
digitalWrite(RELAY_POWER_MP3,HIGH);
|
||||
digitalWrite(RELAY_OUT_MP3_LEFT,LOW);
|
||||
digitalWrite(RELAY_OUT_MP3_RIGHT,LOW);
|
||||
digitalWrite(RELAY_POWER_MP3,LOW);
|
||||
usb = false;
|
||||
bluetooth = false;
|
||||
mp3 = true;
|
||||
|
@ -299,12 +325,15 @@ void loop() {
|
|||
lcdService.print("USB DAC");
|
||||
lcdService.setCursor(0,1);
|
||||
lcdService.print(setUSBinput());
|
||||
// actionUSB();
|
||||
}
|
||||
if(bluetooth){
|
||||
lcdService.print("Bluetooth");
|
||||
// actionBT();
|
||||
}
|
||||
if(mp3){
|
||||
lcdService.print("MP3 module");
|
||||
// actionMP3();
|
||||
}
|
||||
}
|
||||
// bool btnMenuState = digitalRead(BTN_MENU);
|
||||
|
|
Loading…
Reference in New Issue
Block a user