Loop() is also necessary for every Arduino program. It’s called repeatedly as long as your Arduino is powered on. If you have an operation that’s repeated over and over, you put it in the loop() method. However, if you’re trying to do something like blink an LED, you don’t want the Arduino to continually call run, or it’ll turn the LED on and off so fast that you won’t even be able to see it changing. Instead, you use the delay method to pause the program momentarily. Delay takes as its arguments the number of milliseconds to pause. If you wanted to turn an LED off for 1 second, for example, you’d say delay(1000). If you know your program is supposed to be doing something but it doesn’t look like it is, check if you missed a delay and it ran too quickly for you to see!
The other thing to remember in the loop() method is to make sure you cover all your cases. If you’re checking if one of two buttons is pressed, you’ll have to write an if statement to check if the first is on, if the second is on, or if both are off, and write commands for all of them. All your variables have to be in some state at all times. Basically, you’re building a state machine, where the Arduino’s behavior is perfectly defined for each state. If you don’t give part of the Arduino instructions for one of your states, it’ll get confused and do something you don’t expect. Always give all your variables a value, and you’ll be fine!