SOS, really simple question, almost a shame to ask

Hi every one,
I have a Chronograph proyect to play with my kids, running inside our house like a circuit, so I want to build a Arduino Chonograph, I have a 8 digit display, as cool as the one in the car of Return to the future, and it works well on the start, I have to press it to maintain the timer on stop and then once I touch the arrival button it keeps running when I stop pressing, really frustrating because I cannot see the end time, I need the timer to stop once I touch the button, one touch not keep pressing.
This is the code, may be someone can help me Please

/*
#######################################################
Chronometer with hundred of a second.
Works> When Pin 3 gets High, starts counting, as if you left your feet from the button
#######################################################

MAX7219 connections:

MAX7219 chipKIT Uno32
VCC ---------------> 5.0V
DIN ---------------> Pin 12
CLK ---------------> Pin 11
LOAD ---------------> Pin 10
GND ---------------> GND
drukknop op D2 met plus op 3.3 volt
#######################################################

Start/Stop tact switch is connected to INT0 (Pin D3) pin.
*/

#include "LedControl.h"

// Pin 7 to Data In, 6 to Clk, 5 to LOAD
LedControl lc = LedControl(12, 11, 10, 1);

int fsec, sec, minute, reminuto, i, Start;
const int boton = 8;
int val = 0;
int old_val = 0;
int state = 0;
unsigned long previousMillis = 0;
unsigned long interval = 6;
int parador = 1;
void setup()
{
// the zero refers to the MAX7219 number, it is zero for 1 chip
//pinMode(4,INPUT);// Creamos un botón para que reciba la señal de parada
lc.shutdown(0, false); // turn off power saving, enables display
lc.setIntensity(0, 12); // sets brightness (0~15 possible values)
lc.clearDisplay(0);// clear screen
pinMode(boton, INPUT);

fsec = 0;
sec = 0;
minute = 0;
reminuto = 0;
Start = LOW;
lc.setChar(0, 2, '.', false);
lc.setChar(0, 5, '.', false);
Disp_Data();
parador = 1;
int val;
//pinMode(boton,INPUT);

// When the pin 3 gets High starts
attachInterrupt(1, Button_Pressed, HIGH);
// attachInterrupt(2, pulsador, HIGH);

}
void loop()
{
pulsador();//checks if you are pressing to stop
comprobador();// checks if you should keep running
if (Start == 1) {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis > interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
fsec = fsec + 10 * parador;
if (fsec == 100) {
fsec = 0;
sec = sec + 1;
if (sec == 100) {
sec = 0;
minute = minute + 1;
if (minute == 60) minute = 0;
reminuto = reminuto + 1;
//Serial.print("reminuto: ");
//Serial.println(reminuto);
}
}
Disp_Data();
//pulsador();

}

}
}

void Button_Pressed() {
if (Start == 1) {
Start = 0;

}
else if (Start == 0) {
Start = 1;
}
}

void pulsador() {
val = digitalRead(boton);
if ((val == HIGH) && (old_val == LOW)) {
state = 1 - state;
}
old_val = val;
}
void comprobador() {
if (state == 1) {
parador = 1;
}
else {
parador = 0;
}
}

void Disp_Data() {
int ones, tens;
// First display fsec
ones = fsec % 10; // Dont really know what its showing..
tens = (fsec / 10) % 10; //showing hundreds
lc.setDigit(0, 0, (byte)tens, false); //showing hundreds
lc.setDigit(0, 7, (byte)ones, false); //no idea whats this
// Now display sec
ones = sec % 10; //tenths of a second
tens = (sec / 10) % 10;
lc.setDigit(0, 3, (byte)tens, false);
lc.setDigit(0, 1, (byte)ones, false);

// Next display mm
ones = minute % 6; //turns into a minute
tens = (reminuto / 6) % 6;
lc.setDigit(0, 6, (byte)tens, false); //shows 2 minutes
lc.setDigit(0, 4, (byte)ones, false); // shows seconds

}

Just a couple of quick thoughts :slight_smile:

  1. Your code is hard to read because you haven't posted it using code tags for the forum; if you can pop into the IDE - select all ctrl+A - format it (ctrl+T) - copy it to the clipboard in a forum compatible format (ctrl+shift+C) and paste it into a reply here it would be a huge help.

  2. I like using interrupts for detecting key presses (although it seems to be like raising a red flag to a bull in some quarters) - but you need to handle key debounce properly (and it can be a bit tricky unless you know how). If you don't, you'll end up with 2 to 4 interrupts occurring each time you press it.

Let me know if you'd like further help with that.

are you using pin one as an interrupt? isn't pin 1 the TX pin? aren't the interrupt pins 2 & 3

isn't this going to repeatedly generate a interrupt as long as the pin is HIGH? wouldn't you want just a single interrupt when the pin goes HIGH, RISING, or goes low, FALLING.

shouldn't the all button pins be configured as INPUT_PULLUP and depressing the pin pulls the pin LOW

not sure i understand what your buttons do, but believe a more convention approach will work better

// check multiple buttons and toggle LEDs

enum { Off = HIGH, On = LOW };

byte pinsLed [] = { 10, 11, 12 };
byte pinsBut [] = { A1, A2, A3 };
#define N_BUT   sizeof(pinsBut)

byte butState [N_BUT];

// -----------------------------------------------------------------------------
int
chkButtons ()
{
    for (unsigned n = 0; n < sizeof(pinsBut); n++)  {
        byte but = digitalRead (pinsBut [n]);

        if (butState [n] != but)  {
            butState [n] = but;

            delay (10);     // debounce

            if (On == but)
                return n;
        }
    }
    return -1;
}

// -----------------------------------------------------------------------------
void
loop ()
{
    switch (chkButtons ())  {
    case 2:
        digitalWrite (pinsLed [2], ! digitalRead (pinsLed [2]));
        break;

    case 1:
        digitalWrite (pinsLed [1], ! digitalRead (pinsLed [1]));
        break;

    case 0:
        digitalWrite (pinsLed [0], ! digitalRead (pinsLed [0]));
        break;
    }
}

// -----------------------------------------------------------------------------
void
setup ()
{
    Serial.begin (9600);

    for (unsigned n = 0; n < sizeof(pinsBut); n++)  {
        pinMode (pinsBut [n], INPUT_PULLUP);
        butState [n] = digitalRead (pinsBut [n]);
    }

    for (unsigned n = 0; n < sizeof(pinsLed); n++)  {
        digitalWrite (pinsLed [n], Off);
        pinMode      (pinsLed [n], OUTPUT);
    }
}

Hi CJ,
Yes I did not realice about the format, its my first time, I will try to re post the code again with the format.
I have also found out that its not the rule to use interrupts for detecting key presses, looks like there are some problems that come with it, debounce may be?, probably my problem is that when I stop the chronograph I´m some how not ending the code well, or just the interrupt 3 keeps receiving so it keeps running once I drop the button, wich is not what I want.
Note that I´m not pressing the button for the start of the timer I´m releasing it, doing that I make sure that the kids are the ones that drop the button once they start running, kind like a Tag game.
The start button is connected to interrupt 3 and the stop button to interrupt 8.
THANKS A LOT FOR TAKING YOUR TIME TO HELP ME OUT

  • Lista de elementos
    /*
    #######################################################
    Chronometer with hundred of a second.
    Works> When Pin 3 gets High, starts counting, as if you left your feet from the button
    #######################################################

    MAX7219 connections:

    MAX7219 chipKIT Uno32
    VCC ---------------> 5.0V
    DIN ---------------> Pin 12
    CLK ---------------> Pin 11
    LOAD ---------------> Pin 10
    GND ---------------> GND
    drukknop op D2 met plus op 3.3 volt
    #######################################################

    Start/Stop tact switch is connected to INT0 (Pin D3) pin.
    */

#include "LedControl.h"

// Pin 7 to Data In, 6 to Clk, 5 to LOAD
LedControl lc = LedControl(12, 11, 10, 1);

int fsec, sec, minute, reminuto, i, Start;
const int boton = 8;
int val = 0;
int old_val = 0;
int state = 0;
unsigned long previousMillis = 0;
unsigned long interval = 6;
int stopper = 1;
void setup()
{
// the zero refers to the MAX7219 number, it is zero for 1 chip
//pinMode(4,INPUT);// Creamos un botón para que reciba la señal de parada
lc.shutdown(0, false); // turn off power saving, enables display
lc.setIntensity(0, 12); // sets brightness (0~15 possible values)
lc.clearDisplay(0);// clear screen
pinMode(boton, INPUT);

fsec = 0;
sec = 0;
minute = 0;
reminuto = 0;
Start = LOW;
lc.setChar(0, 2, '.', false);
lc.setChar(0, 5, '.', false);
Disp_Data();
stopper = 1;
int val;
//pinMode(boton,INPUT);

// When the pin 3 gets High starts
attachInterrupt(1, Button_Pressed, HIGH);
// attachInterrupt(2, pulsador, HIGH);

}
void loop()
{
stopbutton();//checks if you are pressing to stop
check();// checks if you should keep running
if (Start == 1) {
unsigned long currentMillis = millis();
if (currentMillis - previousMillis > interval) {
// save the last time you blinked the LED
previousMillis = currentMillis;
fsec = fsec + 10 * stopper;
if (fsec == 100) {
fsec = 0;
sec = sec + 1;
if (sec == 100) {
sec = 0;
minute = minute + 1;
if (minute == 60) minute = 0;
reminuto = reminuto + 1;
//Serial.print("reminuto: ");
//Serial.println(reminuto);
}
}
Disp_Data();
//pulsador();

}

}
}

void Button_Pressed() {
if (Start == 1) {
Start = 0;

}
else if (Start == 0) {
Start = 1;
}
}

void stopbutton() {
val = digitalRead(boton);
if ((val == HIGH) && (old_val == LOW)) {
state = 1 - state;
}
old_val = val;
}
void check() {//suppose to check if the stop button has been pressed or not
if (state == 1) {
stopper = 1;
}
else {
stopper = 0;
}
}

void Disp_Data() {
int ones, tens;
// First display fsec
ones = fsec % 10; // Dont really know what its showing..
tens = (fsec / 10) % 10; //showing hundreds
lc.setDigit(0, 0, (byte)tens, false); //showing hundreds
lc.setDigit(0, 7, (byte)ones, false); //no idea whats this
// Now display sec
ones = sec % 10; //tenths of a second
tens = (sec / 10) % 10;
lc.setDigit(0, 3, (byte)tens, false);
lc.setDigit(0, 1, (byte)ones, false);

// Next display mm
ones = minute % 6; //turns into a minute
tens = (reminuto / 6) % 6;
lc.setDigit(0, 6, (byte)tens, false); //shows 2 minutes
lc.setDigit(0, 4, (byte)ones, false); // shows seconds

}

Hi Alexra,

I'm afraid that the code still isn't posted with the right tags - did you "select all" and then a "edit -> Copy for forum" from the IDE before posting?

There are some here who don't believe interrupts should be used for detecting key presses. It's my belief that that position probably came from either (a) a misinterpretation of the fact that because an interrupt is the ONLY way to react fast enough to some high-speed events in some systems that this in some way precludes them from being used to process far slower events like key presses or (b) they've never really worked with them - don't really understand them - have decided that they don't really like them - have thus avoided them - which has in-turn turned more into a form of "dogma" than anything else.

I use them extensively (I wrote my first interrupt handler in assembly language for the original IBM PC back in about 1982) - and they work beautifully; in the context of a key press, fundamentally they allow the registering of a keystroke when it occurs ... which can then be handled in the main loop at a time that's convenient to your code. As with any code it's possible to muck them up just as easily as any other code - so nothing really different there.

Handling debounce is pretty easy; once we get an interrupt we just ignore any further interrupts from that key for a set period of time; I've done a lot of testing and found that 150ms works well (I can't press a key 6 times a second anyway).

So if you'd like to use interrupts then it would be my pleasure to help you; in contrast if you'd like to follow the advice of my learned friends and detect a press by polling for a closure tens of thousands of times an hour (and possibly/probably handling the debounce using a different technique) then please let me know and I'll leave you in their hands.

Cheers,

Colin

use </>

Hi Collin,

Ahhhh, I think that now I learned at least how to copy and paste for the forum.

Yes in the case of accuracy the more the better, I would like to use them, problem is that I still don´t know how.

Thanks a lot again for your help.

/*
  #######################################################
  Chronometer with hundred of a second.
  Works> When Pin 3 gets High, starts counting, as if you left your feet from the button
  #######################################################

  MAX7219 connections:
  -------------------------------------
  MAX7219                       chipKIT Uno32
  VCC      --------------->     5.0V
  DIN      --------------->     Pin 12
  CLK      --------------->     Pin 11
  LOAD     --------------->     Pin 10
  GND      --------------->     GND
  drukknop op D2 met plus op 3.3 volt
  #######################################################

  Start/Stop tact switch is connected to INT0 (Pin D3) pin.
*/

#include "LedControl.h"

// Pin 7 to Data In, 6 to Clk, 5 to LOAD
LedControl lc = LedControl(12, 11, 10, 1);

int fsec, sec, minute, reminuto, i, Start;
const int boton = 8;
int val = 0;
int old_val = 0;
int state = 0;
unsigned long previousMillis = 0;
unsigned long interval = 6;
int stopper = 1;
void setup()
{
  // the zero refers to the MAX7219 number, it is zero for 1 chip
  //pinMode(4,INPUT);// Creamos un botón para que reciba la señal de parada
  lc.shutdown(0, false); // turn off power saving, enables display
  lc.setIntensity(0, 12); // sets brightness (0~15 possible values)
  lc.clearDisplay(0);// clear screen
  pinMode(boton, INPUT);

  fsec = 0;
  sec = 0;
  minute = 0;
  reminuto = 0;
  Start = LOW;
  lc.setChar(0, 2, '.', false);
  lc.setChar(0, 5, '.', false);
  Disp_Data();
  stopper = 1;
  int val;
  //pinMode(boton,INPUT);


  // When the pin 3 gets  High starts
  attachInterrupt(1, Button_Pressed, HIGH);
  // attachInterrupt(2, pulsador, HIGH);

}
void loop()
{
  stopbutton();//checks if you are pressing to stop
  check();// checks if you should keep running
  if (Start == 1) {
    unsigned long currentMillis = millis();
    if (currentMillis - previousMillis > interval) {
      // save the last time you blinked the LED
      previousMillis = currentMillis;
      fsec = fsec + 10 * stopper;
      if (fsec == 100) {
        fsec = 0;
        sec = sec + 1;
        if (sec == 100) {
          sec = 0;
          minute = minute + 1;
          if (minute == 60) minute = 0;
          reminuto = reminuto + 1;
          //Serial.print("reminuto: ");
          //Serial.println(reminuto);
        }
      }
      Disp_Data();
      //pulsador();

    }
  }
}

void Button_Pressed() {
  if (Start == 1) {
    Start = 0;

  }
  else if (Start == 0) {
    Start = 1;
  }
}

void stopbutton() {
  val = digitalRead(boton);
  if ((val == HIGH) && (old_val == LOW)) {
    state = 1 - state;
  }
  old_val = val;
}
void check() {//suppose to check if the stop button has been pressed or not
  if (state == 1) {
    stopper = 1;
  }
  else {
    stopper = 0;
  }
}





void Disp_Data() {
  int ones, tens;
  // First display fsec
  ones = fsec % 10; // Dont really know what its showing..
  tens = (fsec / 10) % 10; //showing hundreds
  lc.setDigit(0, 0, (byte)tens, false); //showing hundreds
  lc.setDigit(0, 7, (byte)ones, false); //no idea whats this
  // Now display sec
  ones = sec % 10; //tenths of a second
  tens = (sec / 10) % 10;
  lc.setDigit(0, 3, (byte)tens, false);
  lc.setDigit(0, 1, (byte)ones, false);

  // Next display mm
  ones = minute % 6; //turns into a minute
  tens = (reminuto / 6) % 6;
  lc.setDigit(0, 6, (byte)tens, false); //shows 2 minutes
  lc.setDigit(0, 4, (byte)ones, false); // shows seconds

}

You did well! Thanks for that - it makes it much easier to work with at my end.

I'll have a look at your code for you now; not sure if I'll get a chance to post anymore tonight (it's 10:41pm here in NZ and I need to get to bed soon) - but if not then I'll definitely post again before this time tomorrow.

1 Like

could you explain more clearly what your buttons do?

Hi gcjr,

Yes, I don´t really know I´m doing most of the time, pin 1 is the TX so every time I have to transfer the code I have to pull it out or it gives me an error (it took me a while to figure it out),

Right now I´m using the interruptor pin 3 to start the Chronograph and pin 8 to stop, but it only stops while I´m pressing it. I have never used INPUT_PULLUP before.

The button in Pin 3, while its pressed on the start keeps the Chronograph stopped, so I hit resset, hold the button, and once I released (kids starts to run), then the chronograph starts running, and then when I press the stop button that its connected to pin 8 it stops, but the problem is that once I release it, it keeps running, so we don´t have a chance to see the final time of the race.

I tried to upload the file, but since I´m a new member I´m not allowed.

Thanks for your help !!!

Ohh thanks a lot and good night, I´m in the opposite side of the word, in Spain.

Good Night

Oh com on, nether reasons a nor b.
The problem is that you can only do something about a flag saying a button has been pressed generated by an interrupt when your code checks that flag. And as a button press is comparatively long, you might as well check it where you would have checked the flag. If the checking of the flag is so long after the button has been pressed and released that you missed it, then your code is badly wrong and the delay in response will cause a user to press again.

That is why interrupts for human button readings are wrong.

I fully understand interrupts and have been using them on micro controllers since 1975.

1 Like

Hi gcjr,

Yes, the Start button is a release button, connected to I3 so when I release it starts running and I8 is supposed to stop the Chronograph, but it only stops it while I´m holding it.

Thanks !!

Hi Alexra in Spain!

Unfortunately, the only Spanish I know is "Marc Marquez"!

I'm working through your code ... so far I've removed some things that "can be done once" that are currently being "done twice" and grouped some things together that belong together - really just to help me understand how the program currently works.

I'd just like to clarify something that I'm not sure of: "do you have one button or two"? If I'm understanding you correctly you have a start button that starts the "stopwatch" when you release it - and you want to stop the "stopwatch" when the stop button is pressed. Is that correct?

using an interrupt is unnecessary and overcomplicated, especially since you use 2 buttons.

you could use the code i posted in reply 3 to check for multiple button "presses" -- specify your button pins in pinsBut []. you could use a switch to set/clear your "Start"

MARC MARCEZ is a great Rider, But I have to admit I still use the helmet from Simon Crafar :slight_smile:

Right now I have to buttons, one for the start, and one for the stop, the plan is to move the start button into a foot pressed button, so when my kid is steping on it, the clock wont be moving, and then move the stop button to the height of their hands so that they will stop the button with their had, kind like in a "Tag" Game.

Thanks again !!

Lol - I use a Schubeth helmet!

It's 1:15am here now - so I need to get to bed. I've done most of the work on your code, but:

  1. Although it compiles correctly, I haven't tested it. I don't have an LED display handy.

  2. I haven't put any code in to handle any debouncing yet. In theory you shouldn't need it but I won't know for sure until I test it tomorrow for you.

I've put a lot of effort into giving variables clear and non-conflicting names - and putting in clear comments (well English ones anyway -- I hope your English is a lot better than my Spanish!).

So at this stage I don't know if it'll work or not, but I wanted you to at least be able to see how simple it is to control it with interrupts; the interrupt handlers simply set or clear a flag - and the counting routine simply runs until the flag is no longer true.

I could do things to tighten everything up - but that would be at the risk of some things being not as clear - so I haven't done that at this stage.

Because the best interrupt mode to use is "falling", you'll probably need to make a minor change to how your switches are attached to the hardware -- I've put some notes on that at the top of the program.

Hope this helps - chat tomorrow!

PS: You can copy it to your clipboard by clicking in the top right of the window it's displayed in here.

/*
  Chronometer with hundredths of a second.

The best interrupt to use to start the stopwatch is "falling" - it triggers when the signal on pin 3 goes from high to low. It would be nice to have one
that triggered when the signal went from low to high, but there isn't a mode that does this - so we need to wire the pin so it's normally high when the switch is
held in - and it's pulled low when the switch is released. So put a high-value resistor around 10,000 ohms between pin 3 and ground - and connect your
switch between pin 3 and your +5v supply. To start the stopwatch press and hold the start button and then press the reset button on the Arduino.

Wire up the stop button so that pressing the button connects pin 8 to ground
*/

#include "LedControl.h"                                                         // include LED control library

LedControl lc = LedControl(12, 11, 10, 1);                                      // define the LED control interface
                                                                                // Pin 7 to Data In, 6 to Clk, 5 to LOAD

int fracSec_t = 0;                                                              // Fractions of a second
int seconds_t = 0;                                                              // Seconds
int minutes_t = 0;                                                              // Minutes
int hours_t   = 0;                                                              // Hours

volatile bool running_t = LOW;                                                  // Stopwatch running?

const byte startButton = 3;                                                     // Start button - attached to pin 3
const byte stopButton  = 8;                                                     // Stop button - attached to pin 8

unsigned long previousMillis = 0;                                               // Previous timestamp
unsigned long interval_t = 6;                                                   // 6ms - used for rounding up > 5ms into next 1 hundreth of a second

void setup()
{
  pinMode(startButton, INPUT);                                                  // Setup the pins the buttons are attached to as inputs
  pinMode(stopButton, INPUT_PULLUP);

  // the zero refers to the MAX7219 number, it is zero for 1 chip               // Setup & initialise the LCD display

  lc.shutdown(0, false);                                                        // turn off power saving, enables display
  lc.setIntensity(0, 12);                                                       // sets brightness (0~15 possible values)
  lc.clearDisplay(0);                                                           // clear screen
  lc.setChar(0, 2, '.', false);
  lc.setChar(0, 5, '.', false);
  
  Disp_Data();                                                                  // Execute display data subroutine

  attachInterrupt(digitalPinToInterrupt(startButton), startButtonPressedISR, FALLING); // Attach ISRs for buttons pressed - needs to activate when pin 3 goes high for first one
  attachInterrupt(digitalPinToInterrupt(stopButton), stopButtonPressedISR, FALLING);                                
}

void loop()
{
  while(running_t)                                                              // Do this while the running flag is true
  {
    unsigned long currentMillis = millis();                                     // Grab a timestamp

    if (currentMillis - previousMillis > interval_t)                            // Have more than 6ms passed?
    {
      previousMillis = currentMillis;                                           // If yes then over-write the previous timestamp with the new one
      
      fracSec_t = fracSec_t + 10;                                               // Increase fraction of a second 1/100th
      
      if (fracSec_t == 100)                                                     // If fractions of a second are now 100 then we need to reset them to zero and increment the seconds count
      {
        fracSec_t = 0;                                                          // Set fractions of a secons back to zero ...
        seconds_t = seconds_t + 1;                                              // ... and increment the seconds
        
        if (seconds_t == 60)                                                    // Are seconds now at 60?
        {
          seconds_t = 0;                                                        // If so then reset them to 0 and ...
          minutes_t = minutes_t + 1;                                            // Increment the minutes
          
          if (minutes_t == 60)                                                  // Are the minutes now at 60?
          {
            minutes_t = 0;                                                      // If so then reset them to 0 and ...
            hours_t = hours_t + 1;                                              // Increment the hours
          }
        }
      }
        
      Disp_Data();                                                              // Display the data
    }
  }
}

void startButtonPressedISR()                                                    // Start button interrupt handler
{
  running_t = true;                                                             // Set the running flag to true
}

void stopButtonPressedISR()                                                     // Stop button interrupt handler
{
  running_t = false;                                                            // Set the running flag to false
}

void Disp_Data() 
{
  int ones, tens;
   
  // First display fracSec_t
  ones = fracSec_t % 10;                                                          // Dont really know what its showing..
  tens = (fracSec_t / 10) % 10;                                                   //showing hundreds
  lc.setDigit(0, 0, (byte)tens, false);                                         //showing hundreds
  lc.setDigit(0, 7, (byte)ones, false);                                         //no idea whats this
  
  // Now display sec
  ones = seconds_t % 10; //tenths of a second
  tens = (seconds_t / 10) % 10;
  lc.setDigit(0, 3, (byte)tens, false);
  lc.setDigit(0, 1, (byte)ones, false);

  // Next display mm
  ones = minutes_t % 6;                                                         //turns into a minute
  tens = (hours_t / 6) % 6;
  lc.setDigit(0, 6, (byte)tens, false);                                         //shows 2 minutes
  lc.setDigit(0, 4, (byte)ones, false);                                         // shows seconds
}

That is not pin 1, that is external interrupt 1 which is associated with pin 3 (on UNO/MEGA). The code doesn't use the recommended

attachInterrupt(digitalPinToInterrupt(interruptPin), Button_Pressed, HIGH);

but this is his code

And the documentation: attachInterrupt() - Arduino Reference

both forms are still supported, but not recommended. The code is clever enough to know that the '1' is not a pin# but an external interrupt #