# Programming Modules

Once you learned about a module, you usually reuse it without much change. There is danger in using modules that you don't understand, but there is also value in treating parts of your Arduino sketch as modules. This serves as a page to document different modules that are used in the tutorial for a quick reference.

void setup()
{
pinMode(PIN,OUTPUT);
pinMode(PIN2,INPUT);
}

void loop()
{
digitalWrite(PIN,NUMBER);
}


void setup()
{
//No need to set pinMode
}
void loop()
{
analogWrite(PIN,NUMBER);
}


### Loops

while (True)
{
\\do something
}

for (int i = 0; i < NUMBER; i++)
{
\\do something NUMBER times.
}


### Conditionals

if (True)
{
\\do something
}

else if (True)
{
\\do something
}

else
{
\\do something
}


#include <Adafruit_NeoPixel.h>

void setup()
{
pixel.begin();
}

void loop()
{
pixel.setPixelColor(PIXEL_NUMBER,pixel.Color(R,G,B));
pixel.show();
allChange(NUM_OF_LED,R,G,B);
}

def allChange(NUM_OF_LED,r,g,b)
{
for (int i = 0; i < NUM_OF_LED;i++)
{
pixel.setPixelColor(i,pixel.Color(r,g,b));
}
pixel.show();
}