As a lazy person who wants to control everything from phone but also too broke to afford alexa, I wanted to make something that controls a lamp and a fan and I got the idea from here .
Fritzing for drawing the circuit diagram.
Arduino IDE for uploading the code on the board.
Arduino uno to take inputs and perform action.
Breadboard for wiring all the components.
Motor driver L298N for providing the suitable current for the motor and controlling its speed and direction.
Motor that acts as a fan/5v fan.
Relay module to control the 9v lamp.
lamp.
Bluetooth Control android application.
Bluetooth Module to commuincate with mobile application.
Resistor 1Kohm to limit the current.
Adapter 9v for powering the circuit.
At first I opened fritzing to connect the components as shown.
Then On arduino IDE I started coding,
At first I declared and initialized some variables:
Motor & relay output pins.
Speed : for changing the motor speed
incomingData: for the data sent from the application.
State variables to make the code more readable.
In void loop, if the data is being sent then, save this data in incomingData variable.
The switch case to check the incomingData, we have two states for the lamp, either on or off depending if you send 1 or 0 from the application to the bluetooth module.
For the fan we have four states:
ON with almost maximum speed 220, so the motor moves forward.
OFF the motor stops.
INC_SPEED to increase the motor speed by 10
DEC_SPEED to decrease the motor speed by 10
Also I had to check if the speed doesn't exceed the maximum limit or drops below the minimum limit
First Connecting the circuit according to the diagram I drew on fritzing.
Then I made a small fan blades using cardboard and mounted it on the motor shaft.
Then I downloaded the bluetooth control application from playStore then I paired & connected the tablet with the bluetooth module after that I made sure that the buttons send the numbers from 0 to 5 as written in the code.
I uploaded the code, plugged the 9v adapter and tested the circuit with dc motor at first.
Then I replaced the motor with the fan.
I wanted to control the 5V dc fan but I didn't have another relay but I asked Menna and she told me I could use the driver module.
I used the driver module to control the fan speed, since it cannot be connected directly to the arduino, because the fan requires more current than the arduino can provide.
I want to make a GUI to interact with the user to choose the songs s/he will play, and I would do that using serial communication.
We made a robot arm that hunts for fish, with Samir & AbdElRahman.