Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino UNO Controlled LED Lighting System with DIP Switch Control

View and Edit Project In Cirkit DesignerImage of Arduino UNO Controlled LED Lighting System with DIP Switch Control

Circuit Documentation

Summary

This circuit is designed to control multiple LEDs using an Arduino UNO microcontroller and a 3-position DIP switch. The LEDs are connected through resistors to various digital pins on the Arduino. The DIP switch is used to select which LEDs are turned on based on the switch positions. The Arduino code reads the switch positions and controls the LEDs accordingly.

Component List

  1. Arduino UNO

    • Description: A microcontroller board based on the ATmega328P.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  2. LED: Two Pin (red)

    • Description: A red LED with two pins.
    • Pins: cathode, anode
  3. DIP Switch 3 Position

    • Description: A 3-position DIP switch.
    • Pins: 1, 2, 3, 4, 5, 6
  4. Resistor

    • Description: A resistor with varying resistance values.
    • Pins: pin1, pin2
    • Properties:
      • Resistance: 10 Ohms, 200 Ohms, 220 Ohms, 10000 Ohms

Wiring Details

Arduino UNO

LED: Two Pin (red)

DIP Switch 3 Position

Resistor

Code Documentation

const int AREA_1_LIGHTS_PIN = 6;
const int AREA_2_LIGHTS_PIN = 7;
const int AREA_3_LIGHTS_PIN = 8;
const int AREA_4_LIGHTS_PIN = 9;
const int AREA_5_LIGHTS_PIN = 10;
const int AREA_6_LIGHTS_PIN = 11;
const int AREA_7_LIGHTS_PIN = 12;

const int PIN_1_SWITCH = 2;
const int PIN_2_SWITCH = 3;
const int PIN_3_SWITCH = 4;

void setup() {
  // put your setup code here, to run once:

  pinMode(AREA_1_LIGHTS_PIN, OUTPUT);
  pinMode(AREA_2_LIGHTS_PIN, OUTPUT);
  pinMode(AREA_3_LIGHTS_PIN, OUTPUT);
  pinMode(AREA_4_LIGHTS_PIN, OUTPUT);
  pinMode(AREA_5_LIGHTS_PIN, OUTPUT);
  pinMode(AREA_6_LIGHTS_PIN, OUTPUT);
  pinMode(AREA_7_LIGHTS_PIN, OUTPUT);

  pinMode(PIN_1_SWITCH, INPUT);
  pinMode(PIN_2_SWITCH, INPUT);
  pinMode(PIN_3_SWITCH, INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:

  if ((digitalRead(PIN_1_SWITCH) == HIGH ) && (digitalRead(PIN_2_SWITCH) == LOW ) && (digitalRead(PIN_3_SWITCH) == LOW )){
    digitalWrite(AREA_1_LIGHTS_PIN, HIGH);
  } else {
    digitalWrite(AREA_1_LIGHTS_PIN, LOW); 
  }

  if ((digitalRead(PIN_1_SWITCH) == LOW ) && (digitalRead(PIN_2_SWITCH) == HIGH ) && (digitalRead(PIN_3_SWITCH) == LOW )){
    digitalWrite(AREA_2_LIGHTS_PIN, HIGH);
  } else {
    digitalWrite(AREA_2_LIGHTS_PIN, LOW); 
  }

  if ((digitalRead(PIN_1_SWITCH) == HIGH ) && (digitalRead(PIN_2_SWITCH) == HIGH ) && (digitalRead(PIN_3_SWITCH) == LOW )){
    digitalWrite(AREA_3_LIGHTS_PIN, HIGH);
  } else {
    digitalWrite(AREA_3_LIGHTS_PIN, LOW); 
  }

  if ((digitalRead(PIN_1_SWITCH) == LOW ) && (digitalRead(PIN_2_SWITCH) == LOW ) && (digitalRead(PIN_3_SWITCH) == HIGH )){
    digitalWrite(AREA_4_LIGHTS_PIN, HIGH);
  } else {
    digitalWrite(AREA_4_LIGHTS_PIN, LOW); 
  }

  if ((digitalRead(PIN_1_SWITCH) == HIGH ) && (digitalRead(PIN_2_SWITCH) == LOW ) && (digitalRead(PIN_3_SWITCH) == HIGH )){
    digitalWrite(AREA_5_LIGHTS_PIN, HIGH);
  } else {
    digitalWrite(AREA_5_LIGHTS_PIN, LOW); 
  }

  if ((digitalRead(PIN_1_SWITCH) == LOW ) && (digitalRead(PIN_2_SWITCH) == HIGH ) && (digitalRead(PIN_3_SWITCH) == HIGH )){
    digitalWrite(AREA_6_LIGHTS_PIN, HIGH);
  } else {
    digitalWrite(AREA_6_LIGHTS_PIN, LOW); 
  }

  if ((digitalRead(PIN_1_SWITCH) == HIGH ) && (digitalRead(PIN_2_SWITCH) == HIGH ) && (digitalRead(PIN_3_SWITCH) == HIGH )){
    digitalWrite(AREA_7_LIGHTS_PIN, HIGH);
  } else {
    digitalWrite(AREA_7_LIGHTS_PIN, LOW);
  }
}

This code sets up the pins for the LEDs and the DIP switch. In the loop function, it reads the state of the DIP switch and turns on the corresponding LED based on the switch positions.