const int ButtonPins[4] = { 2, 3, 4, 5};
const int LedPins[4] = { 10, 11, 12, 13};
void setup()
{
// Serial.begin(9600); // Serial output is not used yet.
// Set the pins for the buttons
for( int i=0; i<4; i++)
{
pinMode( ButtonPins[i], INPUT_PULLUP);
}
// Set the pins for the leds
for( int i=0; i<4; i++)
{
pinMode( LedPins[i], OUTPUT);
}
}
void loop()
{
// check if the buttons are pressed and light up the corresponding LED
for( int i=0; i<4; i++)
{
if( digitalRead( ButtonPins[i]) == LOW)
{
digitalWrite( LedPins[i], HIGH);
}
else
{
digitalWrite( LedPins[i], LOW);
}
}
delay( 10); // slow down the sketch
}