Trying to learn how to code Sketches

Hi there, You initialize variables outside of setup() when you want them to be global. That is available to all parts of your sketch. You can then use them in setup to perform steps BEFORE the main loop.

it is

//Visible everywhere GLOBAL
int a = 1;
int b = 2;
int c = 0;

void setup() {
//Accessing GLOBAL variables inside setup
c = a+b;

//A LOCAL variable
int d = b-a;
}

void loop() {
  // c = a * d; This will error because d does not exist outside of setup it is LOCAL to setup.
  c = a * b; //This is fine because a,b and c are GLOBAL
}