Код для этой схемы, передрал отсюда http://www.compcar.ru/forum/showpost...&postcount=227 и адаптировал под свою задачу
Код:
// Функция проверки нажатия рулевой кнопки
// Возвращает false если кнопка не была нажата
// и true если нажата
// ButtonName принимает значения в зависимости от нажатой кнопки +, -, >, R=>>|, L=|<<, S=SRC, X=None
boolean WheelButonPush_IsPushed()
{
bool result;
result=false;
unsigned long buttonVal;
buttonVal=0;
ButtonName='X';
res_d = analogRead(WheelButtonsPin);
if( res_d < LIMIT) res_d = LIMIT;
delay(10);
res_dt1 = analogRead(WheelButtonsPin);
old_time = millis();
math_time = 0;
while(math_time < 200)
{
real_time = millis();
math_time = real_time - old_time;
res_dt1 = analogRead(WheelButtonsPin);
if(res_dt1 < res_d-LIMIT || res_dt1 > res_d+LIMIT)break;
}
if( math_time > 70)
{
buttonVal=res_d;
ButtonName='X';
// Serial.println (res_d);
if ((buttonVal>25) && (buttonVal<45))
{
ButtonName='-'; //35-36
result=true;
}
if ((buttonVal>60) && (buttonVal<85))
{
ButtonName='+'; //72-73
result=true;
}
if ((buttonVal>110) && (buttonVal<135))
{
ButtonName='S'; //122
result=true;
}
if ((buttonVal>175) && (buttonVal<200))
{
ButtonName='R'; //187
result=true;
}
if ((buttonVal>275) && (buttonVal<295))
{
ButtonName='L'; //285
result=true;
}
if ((buttonVal>415) && (buttonVal<440))
{
ButtonName='>'; //429
result=true;
}
if ((buttonVal>645) && (buttonVal<670))
{
ButtonName='X'; //658-659
result=false;
}
buttonVal=0;
}
return result;
}