this week's assignment we need to Communicate wirelessly with a Smart Circuit via a Graphical User Interface (GUI) on phone or PC.
I wanted to make a circuit with RGB LED and buzzer that I'll need in my final project in which while it's on the LED is colored with green color and the buzzer act like a timer (ticktack) and while it's off the buzzer is off and the RGB LED is red color.
Arduino Uno IDE
Tinkercad
Breadboard
jumper wires
Arduino Uno
USB
Piezo Buzzer
RGB LED
220-ohm resistor
Arduino
USB
first, i used Arduino to read the inputs and outputs using Code Blocks at tinkercad .
I used the USB cable as a voltage source
RGB LED
BUZZER
RESISTOR
Jumper wires
Breadboard
Jumper wires: I used MM wires to connect the circuit.
Breadboard: to place the components on it to ease the connecting process.
220-ohm resistors: to reduce the flow to the led (each color leg connected to a resistor)
on tinkercad
I used tinkercad just to see the connection of the circuit before do the physical one.
the buzzer is on pin 8, cathode on GND
RGB LED:
red on 7, green on 6, blue on 5 and cathode on the GND. each one has a 220 resistor.
Bluetooth module
for the Bluetooth module:
the RX is on the TX (on for recieve and the other for send)
th TX is on the RX (on for recieve and the other for send)
the GND is on the GND
the VCC is on the 5v power on arduino
first and before setup i need to define my pins on arduino
while definition, i needed to define the (int) of the colors of the rgb (RGBset)
as the RGB we need to make the ticktock defition tone
after that, at the setup i need to set the pinmodes (the outputs or the inputs)
after that, at the setup i need to set the pinmodes (the outputs or the inputs)
then, at the loop we need to write the main code.
in my circuit i need the code to have 2 conditions (if and else)
in the if and while the buzzer is on and has its tone the RGB LED is colored Green.
and in else the buzzer is off then the RGB is red colored.
to make the buzzer work "forever" i needed to make a if condition for it
الكود معمول عشان نتحكم في بزر و ليد RGB من خلال أوامر بتيجي عن طريق البلوتوث.
في الأول عرفنا متغيرات: واحد بيخزن الأمر اللي جاي من البلوتوث (زي 1 أو 2)، وواحد بيحدد إذا كان البزر شغال أو مطفي. كمان عرفنا البنات اللي متوصل عليها البزر والليد بألوانه (أحمر وأخضر وأزرق).
عملنا دالة صغيرة خاصة بالـ RGB LED، الدالة دي بتاخد 3 قيم (أحمر، أخضر، أزرق) وتخلينا نقدر نغيّر لون الليد حسب القيم اللي بندخلها.
بعد كده عملنا دالة تانية للبزر بتشغله بصوت "تيك" وبعدها "تاك"، وده بيخلي الصوت شبيه بصوت عقارب الساعة.
في جزء اـ setup جهزنا الأردوينو: شغلنا الاتصال التسلسلي عشان نتواصل مع البلوتوث، وعرّفنا إن البنات اللي موصلين فيهم البزر والليد هيخرجوا إشارات
في الـ loop: الأردوينو بيستنى أي أمر جاي من البلوتوث.
لو وصل الرقم "1" يبقى البزر يشتغل، ويبدأ يعمل صوت "تيك تاك" والليد يضوي أخضر، وكمان يطبع رسالة إن التايمر شغال.
لو وصل الرقم "2" يبقى البزر يطفي، والليد يبقى لونه أحمر، ويطبع رسالة إن التايمر واقف.
وآخر جزء في الكود بيتأكد إنه طول ما البزر حالته شغال، يفضل يعيد صوت "تيك تاك" باستمرار لحد ما يوصل أمر جديد يطفيه.
after ending the code on arduino and finished the connection of the circuit
we need to upload it to the arduino (before click on upload make sure that the RX, TX of the module is off)
open the application (Arduino Bluetooth control)
then select your arduino device and connect it
then open the button& slider to cotrol our circuit with the chars we defined in code (1,2)
physical Circuit
the buzzer is off
Circuit video
the buzzer is on
menna asker once said: ازاي ريسيفر هيتوصل على ريسيفر بالعقل كده امال مين هيبعت السيجنال؟؟
at the connection of the module and the Arduino:
we need to connect the RX to TX for each one
(one acts like receiver at the other one is the sender)
at degitalwrite the "w" is capital letter
Bug #1
this one is on the logic
هحاول اشعبولي الكلام الانجلش مش هيسعفني
دلوقتي انا قولت في الكود انه يشغلي الليد rgb على الالوان دي.
بس قبل السيتاب انا معرفتش الكود انه اصلا فيه rgb عندك ف كان لازم قبل ما احط الrgbset في الloop كان لازم اعرفها قبل السيت اب
والحل اني اعرف اينتجر الحرف للالوان اللي في الليد
Bug #2
the final look
Title of Media
Title of Media