Tarantula3
Published

Arduino Christmas Village

I created this small Christmas Village for my little monster.

BeginnerProtip2 hours8
Arduino Christmas Village

Things used in this project

Hardware components

ELEGOO UNO R3 Board ATmega328P ATMEGA16U2 with USB Cable
ELEGOO UNO R3 Board ATmega328P ATMEGA16U2 with USB Cable
×1
LED, Blue
LED, Blue
×9
High Brightness LED, White
High Brightness LED, White
×9
5 mm LED: Yellow
5 mm LED: Yellow
×9
RGB LED
×1
Resistor 220 ohm
Resistor 220 ohm
×1
Stepper Motor
Digilent Stepper Motor
×1
Stepper Motor Driver
×1
LDR, 5 Mohm
LDR, 5 Mohm
×1

Hand tools and fabrication machines

Cardboard Sheets
4 Paper
Permanent Marker or Pen
Scissor and a Knife
Hot Glue Gun or Wood Glue

Story

Read more

Code

Christmas_Village.ino

Arduino
int LDRPin = A0;   // Pin where the LDR is connected
int LED_1 = 2; 
int LED_2 = 3;
int LED_3 = 4;
int LED_4 = 5;
int LED_5 = 6;
int LED_6 = 7;
int LED_7 = A4;
int RGB_1 = A1;
int RGB_2 = A2;
int RGB_3 = A3;
int RGB_Value = 0;
int ledState  = false;

void setup() {
   Serial.begin(9600);
   pinMode(LED_1, OUTPUT);
   pinMode(LED_2, OUTPUT);
   pinMode(LED_3, OUTPUT);
   pinMode(LED_4, OUTPUT);
   pinMode(LED_5, OUTPUT);
   pinMode(LED_6, OUTPUT);
   pinMode(LED_7, OUTPUT);
   pinMode(RGB_1, OUTPUT);
   pinMode(RGB_2, OUTPUT);
   pinMode(RGB_3, OUTPUT);
}

void loop() {
  RGB_LED_Flash();         // Constant flash 
  
  //int ldrStatus = analogRead(LDRPin);
  //if (ldrStatus <= 100) {  // If no light is detected then turn on the LEDs
    LED_Flash();
  /*} else {                 // If Light is detected turn off all the LEDs
    digitalWrite(LED_1, LOW);
    digitalWrite(LED_2, LOW);
    digitalWrite(LED_3, LOW);
    digitalWrite(LED_4, LOW);
    digitalWrite(LED_5, LOW);
    digitalWrite(LED_6, LOW);
  };*/
  
  delay(200);             // Wait for 200ms
}


void RGB_LED_Flash(){
  switch (RGB_Value) {
    case 0:
      digitalWrite(RGB_1, HIGH);digitalWrite(RGB_2, LOW);digitalWrite(RGB_3, LOW);
      break;
    case 1:
      digitalWrite(RGB_1, LOW);digitalWrite(RGB_2, HIGH);digitalWrite(RGB_3, LOW);
      break;
    case 2:
      digitalWrite(RGB_1, LOW);digitalWrite(RGB_2, LOW);digitalWrite(RGB_3, HIGH);
      RGB_Value=-1;
      break;
  } RGB_Value++;
}


void LED_Flash(){
  digitalWrite(LED_1, ledState);digitalWrite(LED_3,  ledState);digitalWrite(LED_5,  ledState);
  digitalWrite(LED_2, !ledState);digitalWrite(LED_4, !ledState);digitalWrite(LED_6, !ledState);
  ledState = ! ledState;             // Invert the LED state
  digitalWrite(LED_7, HIGH);
}

Credits

Tarantula3

Tarantula3

24 projects • 53 followers
There were 1000+ sperms but I was the fastest one..

Comments

Add projectSign up / Login