How do to execute function just once in void loop? : simplify i want to make counter to execute subrutine if digital read get toogle value. Can you help master, please :D


> ## Code #
> 
> int lastState = 1;
> 
> void setup() {    Serial.begin(115200);    }
> 
> void loop() {
> 
> int currentState = digitalRead(D5);      
if (currentState == 1){
> 
>    if (currentState = !lastState){
>        
aFunction();
>     }
> 
> lastState = !lastState;}
> 
Serial.println ("Still running loop");     
delay (2000); }
> 
> void aFunction(){    
Serial.println("in a function"); }