The interrupt interrupt my mind !

Hi everybody
I'm new player in the Arduino playard
Till now I thought that the setup function run once only and the loop function infinitely until I met this sketch here: Arduino Basics Hardware Interrupt Part 1 - YouTube

void setup() {
pinMode(2, INPUT_PULLUP);
Serial.begin(9600);
attachInterrupt(2,bang,FALLING);

}
void bang(){
Serial.println("BANG!!");
}
void loop() {

}

Why it keep running the setup function after the first push bottom, it should go through the sketch to the loop function an stay there !
Does the loop function run at all ?

Please use code-tags when posting code (the </> button at the top left). It does only run the setup function once. attachInterrupt configures an external interrupt to be triggered when there is a falling edge at pin 2. It also registers a callback-function to be invoked when the interrupt is triggered. Meanwhile your main loop does run, put a Serial.println("I am in loop"); in there and monitor the serial output.

I'm not watching 12 minutes of YouTube. Can you tell us the point in the video where the relevant stuff is?

...R

Robin2:
I'm not watching 12 minutes of YouTube. Can you tell us the point in the video where the relevant stuff is?

...R

I put the link in case that some one does not understand my question and it's important for him to solve my question.
The guy in the video put the interrupt calling in the setup function and that queer for me because if the sketch have to run infinitely it must be in the loop function and in this case, as you see it's not

LightuC:
Please use code-tags when posting code (the </> button at the top left). It does only run the setup function once. attachInterrupt configures an external interrupt to be triggered when there is a falling edge at pin 2. It also registers a callback-function to be invoked when the interrupt is triggered. Meanwhile your main loop does run, put a Serial.println("I am in loop"); in there and monitor the serial output.

Thanks, you explained it very very good and clear

nurusz:
Thanks, you explained it very very good and clear
I really don't know how to use code-tags when posting code :frowning:
I tried to put </> at the beginning but it does not work

If you look at the top of the edit panel you will see a button with </> on it. Just select the code and click the button.

Alternatively type [code]  and [/code} at the start and end of the block of code.

...R

nurusz:
Thanks, you explained it very very good and clear
I really don't know how to use code-tags when posting code :frowning:
I tried to put </> at the beginning but it does not work

You're welcome. This explaines how you use the code tags (look at "7. If you are posting code or error messages, use "code" tags").