
Notes and explanations
Additional Parts & Symbols
No new parts necessary


const int
constant int is an integer (whole number) that will not change. It is not necessary to use constant but helps to clarify things. For more information on data types (float, boolean, etc...) please click here.
if ... else
if .. else statements are probably the most important thing to understand in programming. If the light is blue the engine is on ... else the engine is off. In this case the code looks like this:
if (buttonState == HIGH // The == sign compares the button state to HIGH. In this part of the statement you would not be changing a value, only comparing. Other comparison operators are != (not) < (less than) and > (greater than).
{ digitalWrite(ledPin, HIGH); } // this is what happens if the buttonState == HIGH (light on).
else { digitalWrite(ledPin, LOW); } // this is what happens if the button State doesn't equal HIGH (light off).