[spoiler]
Код: Выделить всё
const unsigned int
APin = A0,
DPin = 15;
/**/
byte i;
unsigned int value = 1023,
b[8] = {
1,//Mute
2,//Mode
3,//Vol+
4,//Vol-
5,//Seek+
6,//Seek-
7,//Answer
8//Hangup
},
cs[8] = {
0xE2,//Mute
0xCD,//Mode -> Play/Pause
0xE9,//Vol+
0xEA,//Vol-
0xB5,//Seek+
0xB6,//Seek-
0xB2,//Answer -> Record
0xB7//Hangup -> Stop
},
delta[8];
void setup() {
pinMode(DPin, INPUT);
Consumer.begin();
for (byte i = 0; i < 8; i++) {
delta[i] = 20;}
}
void loop() {
if (value <= (900) || !digitalRead(DPin)) {
for (i = 0; i < 8; i++)
{
if ((value >= (b[i] - delta[i])) && (value < (b[i] + delta[i]))) {
press(cs[i]);
}
else {
releaseAll();
}
}
}
else {
releaseAll();
}
delay(50);
}