Cant understand this Why is there a last in Boolean debugging(Boolean last)

int switchPin = 8;
int ledPin = 13;
boolean lastButton = LOW;
boolean currentButton = LOW;
boolean ledOn = false;

void setup()
{
pinMode(switchPin, INPUT);
pinMode(ledPin, OUTPUT);
}

boolean debounce(boolean last)
{
boolean current = digitalRead(switchPin);
if (last != current)
{
delay(5);
current = digitalRead(switchPin);
}
return current;
}

void loop()
{
currentButton = debounce(lastButton);
if (lastButton == LOW && currentButton == HIGH)
{
ledOn = !ledOn;
}
lastButton = currentButton;

digitalWrite(ledPin, ledOn);

}

How can the last be compared if there is no value assigned to it in the command

If(last!=current)
{
}

How can the last be compared if there is no value assigned to it in the command

The value of last comes from the value passed into the function

Could you please it to me UK heli Bob thank you

boolean debounce(boolean last)
{
boolean current = digitalRead(switchPin);
if (last != current)

It's a parameter of the function call. If you don't get that, read about functions :slight_smile:

Sorry septillion I am new to the forums I joined today I did not know about code tags I will use the form now thank you