The idea was to create a smart home circuit that allows the user, specially freelancers like me who work from home and don't like to get up and interrupt their flow of work, to control some basic functions in their home from their computer.
Software
Arduino IDE for coding
Processing for GUI on PC
Fritzing for wiring and simulation
Hardware
Arduino UNO board as a brain
HC-05 module for wireless communication
piezo buzzer as a speaker
DC Fan
Resistor 1k ohm for a voltage divider
2 resistors 330 ohm for a voltage divider
Jumper wires for connections
Connecting circuit on Fritzing
Connect +ve fan terminal to pin 8.
Connect -ve fan terminal to common ground on breadboard
Connect +ve buzzer terminal to pin 9.
Connect -ve buzzer terminal to common ground on breadboard.
Connect two 330 ohm resistors with 1k ohm resistor to create a voltage divider to limit the voltage from the Tx of the Arduino to 3.3 volts to be transmitted to the HC-05.
Connect the Tx of the bluetooth module with the Rx of the Arduino.
Connect the 5v and ground pins of the Arduino to the breadboard.
Preparing Processing script
After pairing the bluetooth module with computer, I opened control panel>change bluetooth settings>COM ports to check which port to write in the Processing script.
"COM6" is the outgoing serial data to HC-05.
I sat two buttons in the processing to control the fan and the buzzer.
Hardware connection
I connected the circuit similarly to the simulation connections.
Coding
Code initialisation
Defining pins
Defining Notes used for the song.
Defining the melody.
creating variables.
setup function
Initialise the serial connection to be used for bluetooth communication.
Setting pins mode.
Giving initial values to pins.
Loop function
Waiting for serial input.
setting up the melody.
Checking for user input.
checking for user input before playing another note so that the code works simultaneously.
Circuit demo
Problem 1
I wanted to simulate the circuit before implementing on hardware but I couldn't find the HC-05 module on Tinkercad. Even when I searched online, I found projects using a wifi module not a bluetooth module and it wasn't supported anymore due to security issues.
I decided to use Fritzing and I found that it has simulation feature and searched how to enable it online but after I enabled it I found out there are certain components that can't be simulated including Arduino and HC-05.
I eventually ended up coding and troubleshooting on Arduino IDE and the Arduino board itself.
Problem 2
I created a "switch case" to check the incoming data and decide which function to perform but it created a problem for me because I couldn't perform two functions at the same time for example, if I turn on the music then try to turn on the fan, it doesn't perform the order until it finishes the whole melody playing and I couldn't turn off the music before finishing the melody.
Title of Media
Title of Media
Title of Media