#define BTNN1 2
#define BTNN2 3
volatile int N1=0;
volatile int N2=0;
volatile int chagement=0;
void IsrPinN1 ();
void IsrPinN2 ();
void setup() {
pinMode(BTNN1, INPUT_PULLUP);
pinMode(BTNN2, INPUT_PULLUP);
pinMode(A0, INPUT);
pinMode(A1, INPUT);
Serial.begin(115200);
attachInterrupt(digitalPinToInterrupt(BTNN1), IsrPinN1, RISING);
attachInterrupt(digitalPinToInterrupt(BTNN2), IsrPinN2, FALLING);
}
void loop() {
if (chagement==1)
{
int res=N1+N2;
Serial.print("la somme de ");
Serial.print(N1);
Serial.print(" et ");
Serial.print(N2);
Serial.print(" est = ");
Serial.println(res);
chagement=0;
}
}
void IsrPinN1 ()
{
N1=analogRead(A0);
chagement=1;
}
void IsrPinN2 ()
{
N2=analogRead(A1);
chagement=1;
}