Displaying when Button has been pressed for LED and returning 1
In your button() function, the line

if (current and not last) {


is less common syntax. The more common equivalent is:

if (current &amp;&amp; !last) {


(see https://stackoverflow.com/questions/2376448/the-written-versions-of-the-logical-operators)

This line:

current == last;


Has no effect and is incorrect. This ( “==“ ) is not an assignment but a comparison and does not do what you want it to do.

I also think you have this the wrong way around. You want to save the “last” button state to compare it with the current button state when you call button() the next time. So you would need to set “last” to the current button state, like this:

last = current;


The next time you call button(), “last” contains the previous button state, so your comparison to the current button state will work.

And I think your button detection code would work better if you set last = current each time you call button(), whether a button has been pressed or not. Otherwise your code would repeatedly keep printing “Hey” until you stop pushing the button (unless that’s what you want). Like so:

int button() {
  pinMode(Button, INPUT); 

  int current = digitalRead(Button); 

  if (current &amp;&amp;  !last) {       
    ...
    ...

    Serial.print("Hey");
    last = current; // Insert here
    return 1;
  }

  else {
    pinMode(Button, OUTPUT);
    ...


(This has not been tested but should give you a general idea).