Communicate wirelessly with a Smart Circuit via a Graphical User Interface (GUI) on your phone or PC.
Description:
Build a simple smart circuit that contains at least TWO action components that you can control wirelessly.
Use either the Android GUI or PC GUI to control the action components
Technical Requirements:
The smart circuit contains at least TWO action components connected to an Arduino UNO board (Include a wiring diagram from Tinkercad, Fritzing, or any other tool). ALL action components are acceptable EXCEPT for single color LEDs
The smart circuit communicates wirelessly via a Bluetooth module to a PC or phone
The smart circuit is programmed using Arduino C to perform serial communication (Provide a screenshot of your Arduino C code and *.ino code file)
A Graphical User Interface (GUI) on Phone or PC is used to send data to Arduino to control the action components
The smart circuit is wired and tested with an actual Arduino board and electronic components on a breadboard (Provide a video recording of the final outcome)
The smart circuit is functional and does its intended objective
Despacito Code with Buzzer and LED
Inspiration
I wanted to create a song/ multiple songs that can be played using Buzzer and the lights which are interacting with the song to just act as a disco nightlife :D Let's MAKE SOME NOISE BY THE END OF THE MAKER DIPLOMA!
so i connected a buzzer to arduino and RGB LED to control them with Bluetooth Module HC-O5 (Via Arduino Bluetooth Controller Androis application)
I used Tinker Cad to simulate the circuit design of the bLuetooth module HC05, RGB LED, and pIEZO
Arduino UNO
Adapter 5 volts to supply the arduino with power supply instead of laptop after uploading the arduino code
Bluetooth Controller Module HC-05 which is connected to android through bluetooth
The RGB LED used as an output component to change its color based on the scripted code
Jumpers are the wires type used for connections
220 ohm resistors are used to protect the RGB LED from excessive voltage.
Biezo Buzzer used to produce sound of songs and tones
Arduino Bluetooth Controller android app download it from : https://play.google.com/store/apps/details?id=com.broxcode.arduinobluetoothfree&hl=ar&gl=US
Tinker Cad simulation of RGB LED, PIEZO BUZZER and HC05 Bluetooth Controller
The wiring of the output and input components
The Tinker Cad Simulation
First:
1) The connection of the Piezo Buzzer (output 1) . It has anode (+ve) the tallest arm connected to pin 8 in Arduino and the Cathode(-ve) connected to the common ground GND in arduino (Through the breadboard).
2) The Arduino is connected to the positive +5v and negative GND (Common ground in the breadboard) to supply the components with the voltage power supply.
3) The RGB LED has 4 pins ( Red, Cathode, Blue, and Green) are connected to arduino through pins (9,common ground, 10, and 11) respectively.
4) The HC-05 Bluetooth Module has pins ( VCC, GND, TX, RX) is connected to the arduino ( 5v, common ground, RX, TX) respectively. And we need to make sure that the RX is connected to the TX in the arduino while the TX is connected to the RX in the arduino.
Text Code Idea:
1) Deifne some tones downloaded them from (https://drive.google.com/drive/folders/1KLxsYMhxKcrYebu6URIVcto2w0aXARA2 )
2) I define that pin 8 is the piezo output and 9,10,11 are outputs of the RGB LED.
3) then i paired the bluetooth module with the android mobile and open the arduino bluetooth controller app to connect the HC05 module.
4) I confugured the buttons inputs to be (A,B,C,D,E,and F)
First : Arduino main code before inserting melodies/tones
(1)
input string function for the bluetooth controller input
define the pin modes outputs
serial function to check the output in monitor
(2)
input string A controls RGB LED to be white
turns on the piezo pin 8
turns 9,10,11 which gives white color
input string B controls RGB LED PIN 10 to be GREEN
turns on the piezo pin 8
(3)
input string C controls RGB LED PIN 9 to be BLUE
turns on the piezo pin 8
input string D controls RGB LED PIN 11 to be RED
turns on the piezo pin 8
(4)
input string F turns of RGB LED PIN 9,10,11 to be LOW with no color
turns off the piezo pin 8
Then I inserted the melodies that contain tone commands from ((https://drive.google.com/drive/folders/1KLxsYMhxKcrYebu6URIVcto2w0aXARA2) and the tone command's parameter is as follows tone(output pin of Piezo_8, frequency of the tone in hertz, duration of the tone in milliseconds)
1) AIRTEL TONE SCRIPT in button C, I COPIED IT and inserted it instead of the output pin line of piezo https://drive.google.com/drive/folders/1mg9E1Rw-pRVlok7i65C5ZxvbEzKBiJ_z?usp=sharing
2) Despacito tone script in button B, I COPIED IT and inserted it instead of the output pin line of piezo https://drive.google.com/drive/folders/1JOrQ6CL2uCya7n6LPDQf5W5vWZWC-v9-?usp=sharing
Second : Arduino IDE
PART (1)
char cache;
String inputString = "";
#define C3 130.81
#define Db3 138.59
#define D3 146.83
#define Eb3 155.56
#define E3 164.81
#define F3 174.61
#define Gb3 185.00
#define G3 196.00
#define Ab3 207.65
#define LA3 220.00
#define Bb3 233.08
#define B3 246.94
#define C4 261.63
#define Db4 277.18
#define D4 293.66
#define Eb4 311.13
#define E4 329.63
#define F4 349.23
#define Gb4 369.99
#define G4 392.00
#define Ab4 415.30
#define LA4 440.00
#define Bb4 466.16
#define B4 493.88
#define C5 523.25
#define Db5 554.37
#define D5 587.33
#define Eb5 622.25
#define E5 659.26
#define F5 698.46
#define Gb5 739.99
#define G5 783.99
#define Ab5 830.61
#define LA5 880.00
#define Bb5 932.33
#define B5 987.77
// DURATION OF THE NOTES
#define BPM 120 // you can change this value changing all the others
#define H 2*Q //half 2/4
#define Q 60000/BPM //quarter 1/4
#define E Q/2 //eighth 1/8
#define S Q/4 // sixteenth 1/16
#define W 4*Q // whole 4/4
void setup()
{
Serial.begin(9600);
pinMode(8, OUTPUT); //Buzzer output pin
pinMode(9, OUTPUT); //blue
pinMode(10, OUTPUT); //Green
pinMode(11, OUTPUT); //red
}
void loop()
{
if (Serial.available())
{
while (Serial.available())
{
char inChar = (char)Serial.read();
inputString += inChar;
}
Serial.println(inputString);
while (Serial.available() > 0)
{
cache = Serial.read();
}
if (inputString == "A") //TURNS WHITE
{
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, HIGH);
}
if (inputString == "B") //TURNS GREEN
{
tone(8, 587, 709.720327982);
delay(788.578142202);
digitalWrite(9, HIGH);
delay(10.3082110092);
tone(8, 554, 709.720327982);
delay(788.578142202);
digitalWrite(9, LOW);
delay(5.15410550459);
tone(8, 493, 273.683002294);
delay(304.092224771);
delay(5.15410550459);
digitalWrite(9, HIGH);
tone(8, 369, 273.683002294);
delay(304.092224771);
delay(5.15410550459);
tone(8, 369, 134.52215367);
delay(149.469059633);
digitalWrite(9, LOW);
delay(5.15410550459);
tone(8, 369, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 369, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 369, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 369, 134.52215367);
delay(149.469059633);
digitalWrite(9, HIGH);
delay(5.15410550459);
tone(8, 493, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 493, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
digitalWrite(9, LOW);
tone(8, 493, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
digitalWrite(9, HIGH);
tone(8, 493, 273.683002294);
delay(304.092224771);
delay(5.15410550459);
tone(8, 440, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 493, 273.683002294);
delay(304.092224771);
delay(5.15410550459);
digitalWrite(9, LOW);
tone(8, 391, 412.843850917);
delay(458.715389908);
delay(5.15410550459);
digitalWrite(9, HIGH);
tone(8, 391, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 391, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
digitalWrite(9, LOW);
tone(8, 391, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 391, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 391, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
PART (2)
tone(8, 493, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
digitalWrite(9, HIGH);
tone(8, 493, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 493, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 493, 273.683002294);
delay(304.092224771);
delay(5.15410550459);
digitalWrite(9, LOW);
tone(8, 554, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 587, 273.683002294);
delay(304.092224771);
delay(5.15410550459);
digitalWrite(9, HIGH);
tone(8, 440, 412.843850917);
delay(458.715389908);
delay(5.15410550459);
tone(8, 440, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 440, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 440, 134.52215367);
delay(149.469059633);
digitalWrite(9, LOW);
delay(5.15410550459);
tone(8, 440, 41.7482545872);
delay(46.3869495413);
delay(36.0787385321);
tone(8, 440, 37.109559633);
delay(41.2328440367);
digitalWrite(9, HIGH);
delay(30.9246330275);
tone(8, 440, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 587, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 587, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
digitalWrite(9, LOW);
tone(8, 587, 46.3869495413);
delay(51.5410550459);
delay(30.9246330275);
tone(8, 587, 46.3869495413);
delay(51.5410550459);
delay(20.6164220183);
tone(8, 587, 273.683002294);
delay(304.092224771);
digitalWrite(9, HIGH);
delay(5.15410550459);
tone(8, 659, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 659, 273.683002294);
delay(304.092224771);
delay(5.15410550459);
digitalWrite(9, LOW);
tone(8, 554, 691.165548165);
delay(767.961720183);
delay(314.40043578);
tone(8, 587, 552.004699541);
delay(613.338555046);
delay(5.15410550459);
tone(8, 554, 552.004699541);
delay(613.338555046);
delay(5.15410550459);
digitalWrite(9, HIGH);
tone(8, 493, 273.683002294);
delay(304.092224771);
delay(5.15410550459);
tone(8, 369, 273.683002294);
delay(304.092224771);
delay(5.15410550459);
tone(8, 369, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 369, 134.52215367);
delay(149.469059633);
digitalWrite(9, LOW);
delay(5.15410550459);
tone(8, 369, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 369, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
digitalWrite(9, HIGH);
tone(8, 369, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 493, 46.3869495413);
delay(51.5410550459);
digitalWrite(9, LOW);
delay(30.9246330275);
tone(8, 493, 46.3869495413);
delay(51.5410550459);
delay(20.6164220183);
tone(8, 493, 134.52215367);
delay(149.469059633);
digitalWrite(9, HIGH);
delay(5.15410550459);
tone(8, 493, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
digitalWrite(9, LOW);
tone(8, 493, 273.683002294);
delay(304.092224771);
delay(5.15410550459);
tone(8, 440, 134.52215367);
delay(149.469059633);
digitalWrite(9, HIGH);
delay(5.15410550459);
tone(8, 493, 273.683002294);
delay(304.092224771);
delay(5.15410550459);
tone(8, 391, 273.683002294);
delay(304.092224771);
delay(159.777270642);
tone(8, 391, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
digitalWrite(9, LOW);
tone(8, 391, 41.7482545872);
delay(46.3869495413);
delay(30.9246330275);
tone(8, 391, 37.109559633);
delay(41.2328440367);
digitalWrite(9, HIGH);
delay(36.0787385321);
tone(8, 391, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 391, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 391, 134.52215367);
delay(149.469059633);
digitalWrite(9, HIGH);
delay(5.15410550459);
tone(8, 493, 134.52215367);
delay(149.469059633);
digitalWrite(9, LOW);
delay(5.15410550459);
tone(8, 493, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
digitalWrite(9, HIGH);
tone(8, 493, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 493, 273.683002294);
delay(304.092224771);
delay(5.15410550459);
tone(8, 554, 134.52215367);
delay(149.469059633);
digitalWrite(9, LOW);
delay(5.15410550459);
tone(8, 587, 273.683002294);
delay(304.092224771);
delay(5.15410550459);
tone(8, 440, 412.843850917);
delay(458.715389908);
delay(5.15410550459);
digitalWrite(9, HIGH);
tone(8, 440, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 440, 64.9417293578);
delay(72.1574770642);
delay(5.15410550459);
tone(8, 440, 64.9417293578);
delay(72.1574770642);
delay(5.15410550459);
tone(8, 440, 134.52215367);
delay(149.469059633);
digitalWrite(9, LOW);
delay(5.15410550459);
tone(8, 440, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 440, 134.52215367);
delay(149.469059633);
digitalWrite(9, HIGH);
delay(5.15410550459);
tone(8, 587, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 587, 134.52215367);
delay(149.469059633);
digitalWrite(9, LOW);
delay(5.15410550459);
tone(8, 587, 51.0256444954);
delay(56.6951605505);
delay(30.9246330275);
tone(8, 587, 51.0256444954);
delay(56.6951605505);
delay(10.3082110092);
digitalWrite(9, HIGH);
tone(8, 587, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 659, 273.683002294);
delay(304.092224771);
delay(5.15410550459);
digitalWrite(9, LOW);
tone(8, 659, 273.683002294);
delay(304.092224771);
delay(5.15410550459);
tone(8, 554, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
digitalWrite(9, HIGH);
tone(8, 880, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 880, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
digitalWrite(9, LOW);
tone(8, 880, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
tone(8, 880, 134.52215367);
delay(149.469059633);
delay(5.15410550459);
digitalWrite(9, HIGH);
digitalWrite(10, HIGH);
digitalWrite(11, LOW);
}
if (inputString == "C") //BLUE
{
tone(8, LA4, Q);
delay(1 + Q);
tone(8, LA4, E);
delay(1 + E);
tone(8, LA4, E);
delay(1 + E);
tone(8, LA4, Q);
delay(1 + Q);
tone(8, E5, E);
delay(1 + E);
delay(1 + E);
tone(8, B4, E);
delay(1 + E);
tone(8, C5, E);
delay(1 + E);
tone(8, B4, E);
delay(1 + E);
tone(8, LA4, E);
delay(1 + E);
tone(8, G4, Q);
delay(1 + Q);
tone(8, B4, Q);
delay(1 + Q);
// Line2
tone(8, LA4, E);
delay(1 + E);
tone(8, B4, E);
delay(1 + E);
tone(8, LA4, E);
delay(1 + E);
tone(8, G4, E);
delay(1 + E);
tone(8, LA4, E);
delay(1 + E);
tone(8, B4, E);
delay(1 + E);
tone(8, C5, E);
delay(1 + E);
delay(1 + E);
tone(8, B4, H);
delay(1 + H);
tone(8, LA4, E);
delay(1 + E);
tone(8, G4, E);
delay(1 + E);
tone(8, E4, H);
delay(1 + H);
//Line3
tone(8, LA5, Q);
delay(1 + Q);
tone(8, E5, Q);
delay(1 + Q);
tone(8, G5, Q);
delay(1 + Q);
tone(8, E5, E);
delay(1 + E);
delay(1 + E);
tone(8, E5, Q);
delay(1 + Q);
tone(8, D5, Q);
delay(1 + Q);
tone(8, C5, Q);
delay(1 + Q);
tone(8, LA4, Q);
delay(1 + Q);
//Line4
tone(8, C5, Q);
delay(1 + Q);
tone(8, D5, Q);
delay(1 + Q);
tone(8, E5, Q);
delay(1 + Q);
tone(8, F5, E);
delay(1 + E);
delay(1 + E);
tone(8, D5, W);
delay(1 + W);
tone(8, C5, E);
delay(1 + E);
tone(8, B4, E);
delay(1 + E);
tone(8, LA4, E);
delay(1 + E);
digitalWrite(9, HIGH);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
}
if (inputString == "D") //RED
{
digitalWrite(8, HIGH);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, HIGH);
}
if (inputString == "E") //VIOLETTE
{
digitalWrite(8, HIGH);
digitalWrite(9, HIGH);
digitalWrite(10, LOW);
digitalWrite(11, HIGH);
}
else if (inputString == "F")
{
digitalWrite(8, LOW);
digitalWrite(9, LOW);
digitalWrite(10, LOW);
digitalWrite(11, LOW);
}
inputString = "";
}
}
Button A
Piezo On
Color white
(RED,GREEN,BLUE)
Button B
Despacito Tone
Color Green and Yellow
Button C
Til Air Tone
Color blue
Button D
Piezo On
Color Red
Button E
Piezo On
Color Violette
Button F
Piezo off
RGB LED off
Final Output Arduino Bluetooth Controller that controls two outputs (RGB LED) and Piezo Buzzer
1) I have to wait till the tone end and then i can press the other button, which will play another tone; it cannot be interrupted at the middle i have asked a youtuber (can i play more than one note and shuffle easily through buttons ?) and he responded ("Unfortunately, no - the program runs sequentially, and even if you were to attach multiple speakers, you could not use the "Tone" command to create multiple notes - one note has to stop before the next can sound. )( (Tech at Home Arduino Channel) https://www.youtube.com/watch?v=l4LRhgignoA&t=3s (You can connect to him through his instagram channel via story questions and answers https://www.instagram.com/tech_at_home/?hl=en)
2) The hc05 module is connected to +5v in arduino not 3.3v as it doesn't work or read by the bluetooth finder in any android device.
1) I have learnt how to use the arduino in the biezo output and how to make the controlling wireless through arduino bluetooth controller.
2) I will use this connection in my final project as i will use the blooming effect in moving the parts of the lighting element in response to the user motion in the room, and the bluetooth controller to manually adjust this aoutput actions.
3) I learned how to overcome challenges through trials and errors and resolve the issue by using serial monitors and the avometers along with resolving some bugs related to a missing syntax in the code with some faith that I can do it.
Arduino Processing this week was an additional information which inspired me and i was eager to learn how the applications can be translated to be used in PC and the extra videos have shown how to do so.