MoodLight

by angelastamatis in Circuits > Arduino

222 Views, 0 Favorites, 0 Comments

MoodLight

5F7F6CBA-70B0-424C-A134-BF1E209B1335.jpeg

We decided to create MoodLight, an item that has the function of relaxing you after a long day or peacefully wake you up every morning. The ambient light can also change colors depending on what you like, and the sensor on top can turn them on and off.

One of the biggest challenges that we faced creating MoodLight was programming the Arduino to turn on and off the LED lights that show the time. Other than that, with a little practice, welding the items together was fairly easy. We highly recommend following this instructable because the result was very rewarding to see, and it is very useful to employ in your daily life.

Supplies

This will be the list of materials, tools and software you will be needing:

For materials:

  • 90 LED diodes
  • Three 220 ohm resistors (as a maximum
  • DuPont wire
  • 2 small buttons
  • Perforated phenolic prototype boar
  • Ultrasonic senso
  • 5V LED strip ligh
  • Arduino Mega 256
  • Black conductive adhesive tape
  • Acrylic

For tools:

  • Soldering iron
  • Soldering tin
  • Solder paste
  • Cutting pliers
  • Tweezers
  • Silicone gun
  • Chloroform
  • Cutter
  • Ruler

Softwares:

  • Arduino IDE (Integrated Development Environment), download at: https://www.arduino.cc/en/software
  • Technical drawings for the clock case, download here with the name "TechincalDrawings_Acrylic".

Before starting, we recommend that you follow the instructions as they are to have a good result.

Download the Arduino IDE. You are going to be using the program to put the codification of the time with the LED diodes.

Once you have downloaded the program, copy and paste the next code within it. You may also download the file with the code if you want to. It's the file with the name "MoodLight_Code"

// make an array to save pin configuration of numbers
int minuteR_array[10][7] = { { 1,1,1,1,1,1,0 }, // 0 { 0,1,1,0,0,0,0 }, // 1 { 1,1,0,1,1,0,1 }, // 2 { 1,1,1,1,0,0,1 }, // 3 { 0,1,1,0,0,1,1 }, // 4 { 1,0,1,1,0,1,1 }, // 5 { 1,0,1,1,1,1,1 }, // 6 { 1,1,1,0,0,0,0 }, // 7 { 1,1,1,1,1,1,1 }, // 8 { 1,1,1,0,0,1,1 } // 9 };

int minuteL_array[10][7] = { { 1,1,1,1,1,1,0 }, // 0 { 0,1,1,0,0,0,0 }, // 1 { 1,1,0,1,1,0,1 }, // 2 { 1,1,1,1,0,0,1 }, // 3 { 0,1,1,0,0,1,1 }, // 4 { 1,0,1,1,0,1,1 }, // 5 { 1,0,1,1,1,1,1 }, // 6 { 1,1,1,0,0,0,0 }, // 7 { 1,1,1,1,1,1,1 }, // 8 { 1,1,1,0,0,1,1 } // 9 };

int hourR_array[10][7] = { { 1,1,1,1,1,1,0 }, // 0 { 0,1,1,0,0,0,0 }, // 1 { 1,1,0,1,1,0,1 }, // 2 { 1,1,1,1,0,0,1 }, // 3 { 0,1,1,0,0,1,1 }, // 4 { 1,0,1,1,0,1,1 }, // 5 { 1,0,1,1,1,1,1 }, // 6 { 1,1,1,0,0,0,0 }, // 7 { 1,1,1,1,1,1,1 }, // 8 { 1,1,1,0,0,1,1 } // 9 };

int hourL_array[10][7] = { { 1,1,1,1,1,1,0 }, // 0 { 0,1,1,0,0,0,0 }, // 1 { 1,1,0,1,1,0,1 }, // 2 { 1,1,1,1,0,0,1 }, // 3 { 0,1,1,0,0,1,1 }, // 4 { 1,0,1,1,0,1,1 }, // 5 { 1,0,1,1,1,1,1 }, // 6 { 1,1,1,0,0,0,0 }, // 7 { 1,1,1,1,1,1,1 }, // 8 { 1,1,1,0,0,1,1 } // 9 };

//dots int dots = 33; int ambient = 40;

//Ultrasonic sensor int echoPin = 36; // attach pin 36 Arduino to pin Echo of HC-SR04 int triggerPin = 37; // attach pin 37 Arduino to pin Trigger of HC-SR04 int maxDistance = 50; float distance, duration;

// making the buttons int minuteButton = 38; int hourButton = 39; int minute_button_pressed = 1; int hour_button_pressed = 0;

//function header void Num_Write_Minuto_Derecho(int); void Num_Write_Minuto_Izquierdo(int); void Num_Write_Hora_Derecho(int); void Num_Write_Hora_Izquierdo(int);

//minutes and hours int hour = 15; int minutes = 30; unsigned long now = 0; int hourL = 0; int hourR = 0; int minutesL = 0; int minutesR = 0;

//RGB int R = 2; //red int G = 3; //green int B = 4; //blue

int rVal = 255; int gVal = 24; int bVal = 255;

int rDir = 1; int gDir = -1; int bDir = 1;

int lightCondition = 1;

void setup() { // set pin modes RGB pinMode(R, OUTPUT); // pin Red pinMode(G, OUTPUT); // pin Green pinMode(B, OUTPUT); // pin Blue // set pin modes Minute Right pinMode(5, OUTPUT); pinMode(6, OUTPUT); pinMode(7, OUTPUT); pinMode(8, OUTPUT); pinMode(9, OUTPUT); pinMode(10, OUTPUT); pinMode(11, OUTPUT);

// set pin modes Minute Left pinMode(12, OUTPUT); pinMode(13, OUTPUT); pinMode(14, OUTPUT); pinMode(15, OUTPUT); pinMode(16, OUTPUT); pinMode(17, OUTPUT); pinMode(18, OUTPUT);

// set pin modes Hour Right pinMode(19, OUTPUT); pinMode(20, OUTPUT); pinMode(21, OUTPUT); pinMode(22, OUTPUT); pinMode(23, OUTPUT); pinMode(24, OUTPUT); pinMode(25, OUTPUT);

// set pin modes Hour Left pinMode(26, OUTPUT); pinMode(27, OUTPUT); pinMode(28, OUTPUT); pinMode(29, OUTPUT); pinMode(30, OUTPUT); pinMode(31, OUTPUT); pinMode(32, OUTPUT);

// set pin modes Dots pinMode(dots, OUTPUT); pinMode(ambient, OUTPUT);

// set pin modes Ultrasonic Sensor pinMode(echoPin, INPUT); pinMode(triggerPin, OUTPUT); Serial.begin(9600); Serial.println("Prueba de Sensor");

// set pin modes Buttons pinMode(minuteButton, INPUT); pinMode(hourButton, INPUT);

digitalWrite(dots, HIGH);

}

void readButton(){ hour_button_pressed = digitalRead(hourButton); minute_button_pressed = digitalRead(minuteButton); }

// this functions writes values to the sev seg pins void Num_Write_Minuto_Derecho(int minutesR) { int pin= 5; for (int j=0; j < 7; j++) { digitalWrite(pin, minuteR_array[minutesR][j]); if(pin > 11){ break; } else{ pin++; } } }

void Num_Write_Minuto_Izquierdo(int minutesL) { int pin= 12; for (int j=0; j < 7; j++) { digitalWrite(pin, minuteL_array[minutesL][j]); if(pin > 18){ break; } else{ pin++; } } }

void Num_Write_Hora_Derecho(int hourR) { int pin= 19; for (int j=0; j < 7; j++) { digitalWrite(pin, hourR_array[hourR][j]); if(pin > 25){ break; } else{ pin++; } } }

void Num_Write_Hora_Izquierdo(int hourL) { int pin= 26; for (int j=0; j < 7; j++) { digitalWrite(pin, hourL_array[hourL][j]); if(pin > 32){ break; } else{ pin++; } } }

//Button Funtion void setWatch(){

readButton(); // Set hours if(hour_button_pressed == HIGH){ if(hour < 23){ hour ++; }else{ hour = 0; } }

// Set minutes if(minute_button_pressed == HIGH){ if(minutes < 60){ minutes ++; } if(minutes == 60 && hour < 23){ hour ++; minutes = 0; } if(minutes == 60 && hour >= 23){ hour = 0; minutes = 0; } } }

//Ultrasonic Function void handWave(){ digitalWrite(triggerPin, LOW); delayMicroseconds(2); // Sets the trigPin HIGH (ACTIVE) for 10 microseconds digitalWrite(triggerPin, HIGH); delayMicroseconds(2); digitalWrite(triggerPin, LOW); // Reads the echoPin, returns the sound wave travel time in microseconds duration = pulseIn(echoPin, HIGH); // Calculating the distance distance = duration * 0.034 / 2; // Speed of sound wave divided by 2 (go and back) // Displays the distance on the Serial Monitor if(distance < maxDistance){ //printTime(); digitalWrite(5, LOW); // turn off LED digitalWrite(6, LOW); // turn off LED digitalWrite(7, LOW); // turn off LED digitalWrite(8, LOW); // turn off LED digitalWrite(9, LOW); // turn off LED digitalWrite(10, LOW); // turn off LED digitalWrite(11, LOW); // turn off LED digitalWrite(12, LOW); // turn off LED digitalWrite(13, LOW); // turn off LED digitalWrite(14, LOW); // turn off LED digitalWrite(15, LOW); // turn off LED digitalWrite(16, LOW); // turn off LED digitalWrite(17, LOW); // turn off LED digitalWrite(18, LOW); // turn off LED digitalWrite(19, LOW); // turn off LED digitalWrite(20, LOW); // turn off LED digitalWrite(21, LOW); // turn off LED digitalWrite(22, LOW); // turn off LED digitalWrite(23, LOW); // turn off LED digitalWrite(24, LOW); // turn off LED digitalWrite(25, LOW); // turn off LED digitalWrite(26, LOW); // turn off LED digitalWrite(27, LOW); // turn off LED digitalWrite(28, LOW); // turn off LED digitalWrite(29, LOW); // turn off LED digitalWrite(30, LOW); // turn off LED digitalWrite(31, LOW); // turn off LED digitalWrite(32, LOW); // turn off LED digitalWrite(dots, LOW); // turn on LED digitalWrite(ambient, LOW); } else { /**/ printTime(); doting(); digitalWrite(ambient, HIGH); } }

void clocking(){ if(millis() > now + 60000){//each minute now = millis(); if(minutes < 60){ minutes ++; } if(minutes == 60 && hour < 23){ hour ++; minutes = 0; } if(minutes == 60 && hour >= 23){ hour = 0; minutes = 0; }

} }

void doting(){

digitalWrite(dots, HIGH); delay(600); digitalWrite(dots, LOW); delay(600); }

void printTime(){ hourR = hour%10; hourL = hour/10; minutesR = minutes%10; minutesL = minutes/10;

Num_Write_Hora_Izquierdo(hourL); Num_Write_Hora_Derecho(hourR); Num_Write_Minuto_Izquierdo(minutesL); Num_Write_Minuto_Derecho(minutesR); }

void loop() { clocking(); //setWatch(); handWave(); }

Downloads

50BF7EB5-3742-4019-93D9-9FC5A057A0DD.jpeg

Now it's time to weld the LED diodes on the perforated phenolic prototype board. To complete all the 90 LED diodes, you can start by welding 3 by 3 so it doesn't get messy. Consider that you have to position each diode according to its positive and negative, and weld each of them according to that too. You can cut off the excess diodes with the cutting pliers. Also, you can cut off the excess of the perforated phenolic prototype board with a cutter and a ruler. As a final, you want to achieve this position of the LED diodes, showing a 00:00.

After you weld 3 by 3 diodes, check every once and then the LED lights with the Arduino code that you paste in step 1 to see if they turn on. If they don’t, check if you welded correctly the negatives and the positives. If you have any doubts, here is the link of a simple video tutorial on how to wire LED diodes with its resistors, which you will be needing later on: https://www.youtube.com/watch?v=PtwX_x4sOro

4EA21DC1-5A61-4571-8644-8C752122E54C.jpeg

Once you finish welding all of the 90 LED diodes and you have checked they turn on correctly, weld the DuPont Wires with the according diodes. Then, connect these DuPont Wires to ports on the Arduino Mega 2560. Put black conductive adhesive tape in each bunch of wires so they don’t get any messier with each other. In case of any doubts, you can check this video tutorial to connect these wires correctly: https://youtu.be/M5OadESh0YQ

For this step, you have to weld the wires of the buttons of your clock to the Arduino. You can find some help in the next tutorial video: https://youtu.be/Xz4iVpdMd-w. You don’t need any new codification because everything is written in the code of step 2. Don’t forget to place correctly the positives and the negatives!

Now, you are going to need the LED strip light that goes behind the acrylic frame. That is the light that will act according to the mood! Weld the LED strip light to the Arduino, just like you have done with everything else. You are also going to need the resistors to weld them to the strip light in order to function properly. If you need any extra help, here is a video for you: https://youtu.be/5M24QUVE0iU

C84494D2-98C5-44BB-A4B3-FFF4DD10B772.jpeg

Next, weld the ultrasonic sensor to the Arduino. This piece will go on top of your MoodLight.

Now that you have all the wiring that goes inside the box, it’s time to do the outside part. You just have to download the document with the name "TechnicalDrawings_Acrylic" so you can have the cut done in acrylic, that will be the case material. You just have to find your closest acrylic shop where you can take your document and have it done.

6AF55004-8C15-49E8-8948-A49BD03057F0.jpeg
85CA0C8E-9CCB-4871-9E78-D40F77BC8908.jpeg
2D389A0C-EDD1-4074-9293-18B78B1C79C5.jpeg
5A23A02F-CEA7-4F80-A3F1-7AFBBD3A4F5A.jpeg

Once cut, you will start glueing with chloroform the acrylic face by face while placing the Arduino plus the wires inside. You may use silicone glue and conductive tape to help place everything in order. Be careful with the wires because they are delicate, and we want to avoid any more welding than needed! But if they do break, just carefully weld them back where they were. Remember that the LED strip light goes outside, behind the acrylic frame. Also, put the buttons on its place as well as the Arduino port. You can base yourself on the following technical plans with the measurements to correctly glue each face:

Finally, now that everything is in its place, it’s time to test it running! Just connect the wire of your Arduino to your closest light connector, and see how light changes through the day with time. Enjoy it!

Enjoy!

90839C04-8E2A-4A2F-AC1E-20422C6AFAB3.jpeg

Now you can fully enjoy MoodLight through your day. In the morning or at night, the choice is yours. Try it for yourself and you will see how simple is creating this item just by following the instructions and tutorials. Let us know your experience working on MoodLight and the result afterwards by commenting on the site. Get started and good luck!