プログラム続き。
void setup() {
/* PORTB = 0x00;
DDRB = 0xff;
PORTC = 0x00;
DDRC = 0xff;
PORTD = 0xff; //pullup
DDRD = 0x00; */
pinMode(A0, OUTPUT);
digitalWrite(A0, HIGH);
pinMode(A1, OUTPUT);
digitalWrite(A1, HIGH);
pinMode(A2, OUTPUT);
digitalWrite(A2, HIGH);
pinMode(A3, OUTPUT);
digitalWrite(A3, HIGH);
pinMode(A4, OUTPUT);
digitalWrite(A4, HIGH);
pinMode(A5, OUTPUT);
digitalWrite(A5, HIGH);
pinMode(SS, INPUT);
pinMode(SCK, INPUT);
pinMode(MOSI, INPUT);
pinMode(MISO, OUTPUT);
pinMode(ROT_A_PHA, INPUT_PULLUP);
pinMode(ROT_B_PHA, INPUT_PULLUP);
pinMode(VOL_DATA, OUTPUT);
pinMode(VOL_CLOCK, OUTPUT);
pinMode(VOL_LATCH, OUTPUT);
SPI.setBitOrder(MSBFIRST);
SPI.setDataMode(SPI_MODE1);
SPI.setClockDivider(SPI_CLOCK_DIV16);
SPI.begin();
irrecv.enableIRIn(); // Start the receiver
lcd.begin(16, 2);
lcd.clear();
lcd.noCursor();
delay(10);
send_att_mute_value_lch();
send_att_mute_value_rch();
lcd.setCursor(0,0) ;
lcd.print("ATTENATION LEVEL");
lcd.setCursor(6,1) ;
lcd.print(" MUTE");
PCICR |= (1 << PCIE2);
PCMSK2 |= (1 << PCINT18) | (1 << PCINT19);
sei();
}
void loop() {
#if 0
if (irrecv.decode(&results)) {
switch (results.value) {
// case 0xFDA05F:
case 0xC19046B9: //MUTE
send_att_mute_value_lch();
send_att_mute_value_rch();
mute = 1;
vol_p = 0;
vol_n = 0;
break;
case 0xC1908679: // Vol +
// code = 0xC1908679;
delay(250);
data_inc();
vol_p = 1;
vol_n = 0;
mute = 0;
break;
case 0xC19006F9: // Vol -
//code = 0xC19006F9;
delay(250);
data_dec();
vol_n = 1;
vol_p = 0;
mute = 0;
break;
case 0xC1908976:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xC19049B6:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0XC19021DE:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xC190817E:
break;
case 0xC19009F6:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xC19008F7:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xC19041BE:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xC190A15E:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xC190C13E:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xC19001FE:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xFFFFFFFF :
if( vol_p != 1 /*&& code != 0xC19006F9 */ && mute != 1){
data_dec();
delay(180);
}
if( vol_n != 1 /*&& code != 0xC1908679 */ && mute !=1 ){
data_inc();
delay(180);
}
break;
}
delay(250);
irrecv.resume();
code = 0;
}
#endif
//以下、秋月リモコン用
if (irrecv.decode(&results)) {
switch (results.value) {
case 0xFDA05F: //MUTE
//case 0xC19046B9: //MUTE
send_att_mute_value_lch();
send_att_mute_value_rch();
mute = 1;
vol_p = 0;
vol_n = 0;
break;
case 0xFD906F: // Vol +
code = 0xFD906F;
delay(250);
data_inc();
vol_p = 1;
vol_n = 0;
mute = 0;
break;
case 0xFD807F: // Vol -
code = 0xFD807F;
delay(250);
data_dec();
vol_n = 1;
vol_p = 0;
mute = 0;
break;
case 0xFD00FF:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xFD40BF:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0XFD20DF:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xFD609F:
break;
case 0xFD10EF:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xFD50AF:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xFD30CF:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xFDB04F:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xFD708F:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xC19001FE:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xFD08F7:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xFD8877:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xFD48B7:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xFD28D7:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xFDA857:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xFD6897:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xFD18E7:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xFD9867:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xFD58A7:
vol_n = 0;
vol_p = 0;
mute = 0;
break;
case 0xFFFFFFFF :
if( vol_p != 1 && code != 0xFD807F && mute != 1){
// if( vol_p != 1 && code == 0xFD906F && mute != 1){
data_dec();
delay(150);
}
if( vol_n != 1 && code != 0xFD906F && mute !=1 ){
//if( vol_p != 1 && code == 0xFD807F && mute != 1){
data_inc();
delay(150);
}
break;
}
delay(220);
irrecv.resume();
code = 0;
}
}