Introduction: Andruino Shelf ®
Many times happened that I forgot to turn off lights when I go to sleep or I'm just too lazy to get up when I'm resting, so I decided to make a lamp I can control without having to get up. Additionaly, I wanted it to be multifunctional and with options of choosing color of light, so I can make different ambients.
This project represents integrating RGB LED lighting into my modular shelf design. Lights (switch, color and intensity) are controled by application on Android smart phone via Bluetooth. Also, there is a sound controled switch (hand clap). I have made 3d model in Grasshopper, which makes this design flexible and adaptable to different spaces. It consists of two parts, of which one contains lamp, and the other one not. Parts can be combined with each other or be independent. The shelf is made of wood, and the lamp is made of laser cutted white acrylic sheets. Pattern of lamp holes is based on Voronoi diagrams with attractor point. Enough about design, lets do some fun!
So, to make this interaction I have used:
- Eduardo board (compatibile with Arduino Duemilanove)
- Bluetooth module HC-05
- 11 kΩ and 22 kΩ resistors (for voltage divider for BT module)
- Sound sensor
- 1m of RGB LED strip (SMD 5050)
- 3x IRF510 (MOSFET Transistors)
- 12V power adapter
- Voltage regulator
- 330nF 100nF ceramic capacitors
- Android application
Step 1: LED RGB Strip
In this project I had SMD 5050 LED strip, which contains 300 RGB diodes on 5m. I have used only 1m of it.
In order to emit the light of adequate intensity, it is necessary to know how much current diodes require and what the working voltage is. The LED strip works with a 12V power supply. 1m contains 60 diodes. The working current per meter is 1.2A, which is 20mA per diode. Since the tape requires 12V, and the Arduino output gives 5V, it is necessary that the configuration contains the transistor. Transistors are electronic components that take up a small amount of energy and amplify it. In this project is used type of N-MOSFET transistor (IRF510), which provides a working voltage of 5.6 A (so it can power more than 1m meter that is used here). RGB strip needs three transistors, one for each of the channels. The transistor has three pins - Gate, Drain, and Source. By connecting the power to the gate, an electric field is generated, which regulates the flow of current between the drain and the output. It can be viewed as a resistor, where the difference in voltage at the input and output controls the resistance between the drain and the output - it reduces it. With N channel MOSFET, the output is connected to GND. In order to be active, the voltage at the input must be increased. Each of the three MOSFETs is connected to the Arduino board as follows: the gate is connected to Arduino digital pin (pins 9, 10 and 11), the drain is connected to the R / G / B channel of the LED strip, and the source is connected to GND of Arduino.
As the LED strip works with 12V power supply and the Arduino 5V, it is necessary to put a 5V voltage regulator with two capacitors. The regulator is a component that converts the AC into DC. Capacitors are components that store electric energy in the form of an electric field, between two electrodes separated by an insulator. The insulator increases the capacitance (charge and voltage ratio). I have used ceramic capacitors of 330nF and 100nF.
Step 2: Bluetooth Module
For wireless light manipulation, I have chosen Bluetooth moduo HC-05.
Moduo has Rx (Receive) and Tx (Transmit) pins, and power pins of 5V and GND. Arduino has the Software Serial option which allows any pin to be converted into a serial pin. Serial pins are pins that allow reception and transmission of serial data. The Rx pin of the Bluetooth module connects to the Tx pin of Arduino (pin 4), and the Tx pin of Module to the Rx pin of Arduino (pin 2). The connection between the Tx of Arduino and the Rx of Module must be carried out via a voltage divider, as Arduino gives 5V and the moduo supports only 3.3V. The difference in the voltage is solved by two resistors, where one is twice larger than the other - 11kΩ and 22kΩ. The Tx pin of Module can be connected directly to the Rx pin of Arduino, because the signal that emits Bluetooth is strong enough that Arduino receives it.
Step 3: Android Application
To control lights with the phone, it is first necessary to install the application on the Android phone. When it's done, it is necessary to activate the Bleutooth signal on the phone and connect it to the module with the Pair device option. When the connection is made, the application offers a selection of connected devices, where you need to select moduo (HC 05) which opens options for lights manipulation. Options for switching on and off are in the form of a button, and selection of color and intensity in the form of a slider, one for each of the three RGB channels. Sliders have values in range 0-255, because this is the range of RGB color chanels. When Bluetooth is active, it emits a signal that allows connection with Android. The values from the slider in the application are, in the form of bytes, sent via the Bluetooth transmitter to the Arduino receiver. Based on the obtained values, Arduino executes a command given by the code.
Step 4: Sound Sensor
To enable turning lights by hand clap or some other sound command it is necessary to connect the sound sensor. The sound is detected by the microphone located on the sensor. The sound level can be set via the potentiometer on the module itself. I also have set the value in the code that need to be exceeded in order to sensor detects a sound. The sensor works at 5V, so it's possible to connect it with Arduino directly. One pin is connected to 5V on Arduino, the other to GND, and the third pin "A0" is connected to 0 analogue pin on Arduino board.
Step 5: Arduino Code and Wiring
Let's get it all together now!
Each Arduino has at least two serial ports (Rx and Tx), and some have more. The board used for this work has a serial port on pins 0 and 1. For communication with other devices, it must be used one of the digital pins. And in order for a digital pin to make serial communication, it is necessary to declare these pins through SoftwareSerial. In this way, pins 2 and 4 are assigned to be used to connect to the Bluetooth module. Pin 2 is Rx, or Reciever, and pin 4 is Tx, or Transmitter.
EEPROM represents a memory that stores the desired values when the board turns off. Here, this memory is used for storing values that was set before the light is turned off, so when you turn it on next time, you have the same color and intensity of light you had last time. Loading the previous value stored in the EEPROM memory is done via analog output.
The brightness values are obtained from the analog output, since this value is in the range 0-255. The turning on and off functions are done via digital output, where the values are nur high or low.
The first part of code is about declaring variables. The next one about decalring functions - BT connection and sound detection. The last part is the program itself.
The program code consists of two parts: the basic - setup () and the program that is constantly repeating - loop ().
The first section defines the input and output data and connection to a computer or other device. Input data are the values read from the sound sensor, and the output data are the values obtained in the functions for each of the RGB channels.
The second part of the program is continuously executed. When the set sound value is registered, the function for turning the lights on by the sound command will be executed. Also, if a Bluetooth signal is available at any time, the communication function with Android will be performed.
Step 6: Result
Finally, the result!
Now I have multifunctional shelf that make lights of any color or mood I want, and fits in any ambient. And the best thing is, I can control it without having to get up.
You can apply this way of lighting anywhere you want.