Sources Of Inspiration
inspired by the fan at our homes that when we press the ON button a sound is released.
This week's assignment is to Build a simple smart circuit with at least TWO action components that you can control wirelessly.
so, i made a fan that when it works a buzzer works with it too.
I used TINKERCAD software to simulate my circuit before implementing it.
and Arduino IDE software to write my circuit Arduino C text
Materials
Electric Components
ARDUINO UNO
jumpers
Buzzer
Bluetooth Module
DC fan
9V adapter
Relay
My circuit utilizes ARDUINO to control 2 action components which are the buzzer and fan.
the circuit includes a Bluetooth module so I can control it from my mobile.
so, when i send number 1 to my circuit the fan and buzzer will work together and when i send number 2 it will be turned off.
Circuit Wiring Diagram
Implementing components & Connections
ARDUINO 5V ➡️+VE RAIL (BREAD BOARD)
ARDUINO GND ➡️-VE RAIL (BREAD BOARD)
Buzzer
-ve ➡️ -ve rail
+ve ➡️ pin ~2
Fan
+ve ➡️ CM (relay)
-ve ➡️ -ve (rosetta)
+ve rosetta➡️ ON (relay)
Other Side Of Relay
IN ➡️~7
GND➡️GND rail
VIN ➡️+ve rail
Bluetooth Module
VCC➡️+ve rail
GND➡️-ve rail
TX➡️RX (ARDUINO)
RX➡️TX (ARDUINO)
Text Code
Before Void Setup
Before writing any code (orders) first i define the component's status before Void setup to preserve a place called x on the ARDUINO memory.
So I wrote all the pins and their components I connected before in the form of integers (int).
for the relay pin I put it on ~7 and the buzzer on ~3
and for the Bluetooth module I made it`s default number 0.
Make sure that the brackets, symbols & semicolons are in their places with the right number.
Void Setup
I am supposed to write any action I want to repeat only once Also it is preferable to define the outputs & inputs here so I don`t have to define it again in a void loop and to be easy for the Arduino to read.
My outputs in this circuit are a fan and buzzer.
Void Loop
For any order that I want to be repeated through the process I wrote it under the void loop.
I used the if else condition to make the buttons via my mobile link with the fan and buzzer.
what do I want to achieve?
when the user presses (send) number 1 on his mobile application ➡️ the fan and buzzer are ON.
and when the user presses (send) number 2 on his mobile application ➡️ the fan and buzzer are OFF.
Circuit components and connections
Final Product Functional
after wiring and connecting the circuit and checked that my code is syntax wise is right my fan is working and the buzzer don`t want to.
i thought of changing the idea as i asked and searched a lot but with no results, until one of the instructors told me that there are 2 brackets left and it is not a syntax error that can appear while uploading but it is a logical error.
The 2 brackets needed
The circuit before discovering the problem
The reason was that: the digital write (buzzer, LOW) wasn`t inside any condition so it was happening with each reading for the loop and it was low but after I put the brackets it started reading it low only when I sent 2.