Arduino Holiday Lights || Simple Decorations

in Project HOPE2 months ago

▶️ Watch on 3Speak


Living in a new home and all, there are certain things you take with you and certain things you don't. Having said that, we decided to not spend any money on unnecessary things and instead save that money we would have spent for future travel. This includes holiday/christmas decorations. So no lights, no tree, etc. Nothing except good delicious food of course, that definitely falls under the "necessary" category.

But being the geek that I am, I did something to decorate anyway, which didn't cost me anything but some time and coding. As it happens I have 2 Arduino Uno's at home. These are microcontrollers, which are mini-computers, simply said, that enable someone to automate simple mechanical tasks or movements. A microcontroller consists of a processor that does all of the operation, and it also has various input and output pins to send and receive signals to and from different components.

Coincidentally I am also a university lecturer in this subject, so it was smooth sailing from the start. Due to my position teaching this subject I also have a full starter kit of different components. So with little time, and a lazy attitude xD, I decided to do something simple in the form of flickering Christmas lights.

IMG_20201225_231449.jpg

So I opened up the starter kit and went to work. And in about half an hour I had my setup.

IMG_20201230_221046.jpg

It's a simple setup, with the green led lights connected to one digital output and the red led lights connected to another. Of course each led is in series with a 330 ohm resistor to make sure they don't burn out due to overload. To close the circuit all led lights lead to a ground port of the Arduino.

IMG_20201230_221708.jpg

Before the action starts, I had to program the behavior of the Arduino. The behavior of the two digital ports used to be exact. Here's the code for any enthusiasts. But them again, an enthusiast would know how to make this from scratch. :) I had the two different colors alternate and then light up at the same time, with decreasing delay intervals, meaning they would flicker faster each time and then reset and repeat the process.


int red = 13;
int green = 7;
int second = 1000;

void setup() {
  pinMode(red, OUTPUT);
  pinMode(green, OUTPUT);
}

void loop() {
  int delayAll = second;
  while(delayAll > 100) {
    for (int i = 0 ; i < 3 ; i++) {
      alternate(delayAll);
    }

    for (int i = 0 ; i < 3 ; i++) {
      sameTime(delayAll);
    }

    delayAll = delayAll/2;
  }
  
}

void alternate(int delayTime){
  digitalWrite(red, HIGH);
  digitalWrite(green, LOW);
  delay(delayTime);
  digitalWrite(red, LOW);
  digitalWrite(green, HIGH);
  delay(delayTime);
}

void sameTime(int delayTime){
  digitalWrite(red, LOW);
  digitalWrite(green, LOW);
  delay(delayTime);
  digitalWrite(red, HIGH);
  digitalWrite(green, HIGH);
  delay(delayTime);
}

Once the code on my laptop was finished, I uploaded that through the Arduino software.

Screenshot_68.png

The moral of the story is that you don't need to spend money to bring a little bit of positive spirit into your home. Even if you don't have a microcontroller like me, something is still possible. A friend of mine, for example, made a tree and a reindeer out of cardboard boxes and that already cheered up his whole living room.


So, how did you decorate this year?


[ Uniquely Clever Sign Out Message Goes Here ]


▶️ 3Speak

Sort: