// these constants won't change:
const int ledCount = 4; // the number of LEDs in the bar graph
const int dipCount = 4;
int ledPins[] = {
2, 3, 4, 5
}; // an array of pin numbers to which LEDs are attached
int dipPins[] = {
8, 9, 10, 11
};
void setup() {
Serial.begin(115200);
// loop over the pin array and set them all to output:
for (int thisLed = 0; thisLed < ledCount; thisLed++) {
pinMode(ledPins[thisLed], OUTPUT);
}
for (int thisDip = 0; thisDip < dipCount; thisDip++) {
pinMode(dipPins[thisDip], INPUT_PULLUP);
}
}
void loop() {
if(digitalRead(dipPins[0])==HIGH)
{
Serial.println("DIP1 is HIGH");
digitalWrite(ledPins[0], HIGH);
}
else
{
Serial.println("DIP1 is LOW");
digitalWrite(ledPins[0], LOW);
}
delay(1000);
}