Sleepy Application
My design idea is based on a daily need, which is to transform the bedroom into a smart room.
where the opening and closing of the room's lighting is controlled, in addition to opening and control warm light color using a mobile application.
This is done using a Bluetooth module that controls a color from led and a relay on the room's lighting by sending the commands written on the application.
Using thinker CAD to build and simulate the circuit
Using Arduino IED install coding to arduino board
Using Application: Android Phone GUI
to connect Arduino with mobile phone
Electronics I used in the Assignment
breadboard
bluetooth module
Arduino UNO
relay module
RGB LED
jumper wires
adaptor 9v
lamp 9 v
Tools and Materials to build the Enclosure
cutter
pins
recycled card board
1st step building Circuit on Thinker CAD
Components Kit
input Devices : bluetooth module
Output Devices : relay _lamp 9V_RGB LED
brain : the Arduino UNO board
Power Management : adaptor 9 V _ adaptor 5 V
writing coding on Arduino IED
Explaining the code logic and How to planning it
char incomingData = '0';
void setup() {
Serial.begin(9600);
pinMode(13, OUTPUT);
pinMode(12, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
}
void loop() {
while (Serial.available() == 0);
incomingData = Serial.read();
if (incomingData == '1') {
digitalWrite(12, HIGH);
digitalWrite(13, HIGH);
} else if (incomingData == '2') {
digitalWrite(12, LOW);
digitalWrite(13, LOW);
} else if (incomingData == '3') {
analogWrite(9, 50);
analogWrite(10, 20);
analogWrite(11, 20);
} else if (incomingData == '4') {
analogWrite(9, 50);
analogWrite(10, 100);
analogWrite(11, 0);
} else if (incomingData == '5') {
analogWrite(9, 100);
analogWrite(10, 0);
analogWrite(11, 30);
delay(3000);
analogWrite(9, 0);
analogWrite(10, 0);
analogWrite(11, 0);
delay(1000);
analogWrite(9, 0);
analogWrite(10, 50);
analogWrite(11, 50);
delay(3000);
} else if (incomingData == '6') {
analogWrite(9, 0);
analogWrite(10, 0);
analogWrite(11, 0);
} else {
Serial.println("Invalid Value");
}
incomingData = Serial.read();
Serial.println(incomingData);
}
The Bluetooth module sends a signal in the form of a number or a letter.
Therefore, I define that number in the code by writing " char incoming Data = '0'; "
Thus, any number sent on the application to the Bluetooth module and from it to the Arduino comes in place of the number zero.
To read the information inside the Arduino, set the serial print to with value speed for reading it 9600.
Define the inputs or outputs in the circuit and their relationship to the Arduino.
Therefore, I defined the pins and their numbers in the circuit as outputs.
In void loop, the action to be repeated is written in a circuit.
To control the action through the Bluetooth module, a specific action number is specified when it is entered from the application and connected to the Arduino through Bluetooth.
The Bluetooth says to send a signal to the pin to execute this action.
To write this in the code, a function is created using the IF Condition, where the action is written if the Arduino receives a certain number and by changing the number the action changes, so this action is explained in ELSE IF
By specifying numbers from 1 to 6 available in the application, the code was divided into 6 events, each event has a number that works when selected.
This is done by specifying the pin to be turned on when selecting high, and the pin to be closed when selecting low.
As for the analog pins, it is possible to enter a number from 0 to 255, which allows controlling the color degrees of the RGB LED lamp.
Also, to operate multiple colors, a delay is written with a specific value, in which the Arduino sends a signal to another color of the lamp, changing the color shade.
Action must be specified if none of the six numbers are selected write "Invalid Value" on serial print.
I used It also to assemble the electronic parts in it, to make it easier and clearer to wiring.
making a simple cardboard from recycled pizza box
I used it as a bedroom simulation with lighting units.
wiring electronic circuit
WIRING ARDUINO POWER : using power supply 5V_5A, and connect to ARDUINO throw "power pin 5v" and "ground" pin using crocodile wires and jumpers
2. WIRING LAMP 9V WITH RELAY AND ARDUINO : powering circuit with adaptor 9v for lamp and connect lamp with relay to balance between adaptor power (9v) and ARDUINO power (5v)
connect lamp "ground" with adaptor "ground" and positive with "NO" (normally open ) with relay , and connect common on relay with adaptor "positive "
then connect relay with ARDUINO, connect "VR" with "5v" ARDUINO and "GND" with "ground" ARDUINO and "V IN" with signal pin (I used pin 13)
wiring relay
3. WIRING RGB LED : connect "ground" RGB LED with "ground" ARDUINO and color pins connect every wire with resistor 220 OUM on breadboard and connect to analog pins 9-10-11
( I used analog pins because I need Various colors, I will give pins Variable values from (1:255)
WIRING RGB LED
4. wiring BLUETOOTH module : connect "VCC" to "5v" ARDUINO , connect "GND" to "ground" ARDUINO, connect "TXD" to "RX" pin on ARDUINO and connect "RXD" with ground to resistor 1k OUM then to TX pin on ARDUINO
wiring BLUETOOTH module
all circuit connected on one breadboard and wired with jumpers and crocodiles
choose BLUETOOTH device after pairing to mobile
choose buttons to control pins
update buttons with chosen number in code
check every button
change number according the code
lamp opened when I choose button 1 on application
lamp closed when I choose button 2 on application
led opened with purple color when I choose button 3 on application
led opened with turquoise color when I choose button 4 on application
led opened with warm color when I choose button 5 on application
led closed when I choose button 6 on application
A video recording of the final outcome
The challenge I faced was in the way of entering power to the Arduino and closing the circuit with its electronic components.
I used a 9 volt adaptor for powering Arduino, but all circuit component need 5v to work and 5 v from Arduino was not enough to power all component
I used 5 volt power supply and connected it to the Arduino and breadboard to give power for all components
challenge was how to connect to Arduino, I used "5v pin" as input voltage from power supply
power ARDUINO with 5A power supply from power pin 5V and ground
power ARDUINO with 9V adaptor from power pin Vin and ground
how to power ARDUINO from pins
using 5v pin as power input