Check out example codes for "arduino falling edge". It will help you in understanding the concepts better.

Code Example 1

int button = 2;
int flag;
int readbutton;
void setup(){}
void loop(){
  readbutton = digitalRead(button);
  if(readbutton>flag){
  //your code here
  flag=readbutton;
}
if(readbutton==0){
flag=0;
}

Learn ReactJs, React Native from akashmittal.com