The idea of the assignment for this week is to communicate wirelessly with a Smart Circuit via a Graphical User Interface (GUI) on
The idea is to make a circuit with two components. I choose to make a simple circuit with led and buzzer.
This circuit maybe can be on a large scale in a waking system that controls all lights in the room and makes a buzz to wake the person by Bluetooth.
Software
Arduino IDE
Arduino Bluetooth control app
TinkerCad
Materials
Resistor 330/220 Ohm
Bluetooth sensor
Wires
BreadBoard
green LED
Buzzer
USB Cable
Arduino UNO
Designing
1- install all materials we are going to use
Arduino Uno.
jumpers.
USB cable.
Green LED.
Resistor.
breadboard.
Bluetooth sensor.
Buzzer.
2- Connect all components on the breadboard (Parallel).
3- start the STIMULATION .feature to make sure every component is working.
Coding
char recData = '0';
#define LED 13 // definition of pin number for LED.
#define BUZZER 12// definition of pin number for BUZZER.
void setup() {
Serial.begin(9600);
pinMode(LED, OUTPUT);
pinMode(BUZZER, OUTPUT);
}
void loop() { //To light the LED with mobile
while (Serial.available() == 0)
;
recData = Serial.read();
Serial.println(recData);
if (recData == '1') { // TO light the LED ONLY
digitalWrite(LED, HIGH);
digitalWrite(BUZZER, LOW);
} else if (recData == '2') {// TO light the BUZZER ONLY
digitalWrite(LED, LOW);
digitalWrite(BUZZER, HIGH);
} else {// TO TURN OFF ALL when I click any other buttons // To stop the loop if no signal is sent from mobile
digitalWrite(LED, LOW);
digitalWrite(BUZZER, LOW);
}
}
I connect the +ve wire of LED to pin 13 & -ve wire of LED to pin GND on a GND of Arduino, +ve wire of buzzer to pin 12 & -ve wire of buzzer to pin GND on a GND of Arduino, and As in the previous pic, I connect Bluetooth sensor.
circuit after connecting it
1- Connect all components on the breadboard and Arduino Uno.
2- Make the block code on tinker cad.
3- Writing the code on Arduino IDE.
4- Uploading the code to the Arduino UNO.
char recData = '0';
#define LED 13 // definition of pin number for LED.
#define BUZZER 12// definition of pin number for BUZZER.
void setup() {
Serial.begin(9600);
pinMode(LED, OUTPUT);
pinMode(BUZZER, OUTPUT);
}
void loop() {
while (Serial.available() == 0)
;
recData = Serial.read();
Serial.println(recData);
if (recData == '1') { // TO light the LED ONLY
digitalWrite(LED, HIGH);
digitalWrite(BUZZER, LOW);
} else if (recData == '2') {// TO light the BUZZER ONLY
digitalWrite(LED, LOW);
digitalWrite(BUZZER, HIGH);
} else {// TO TURN OFF ALL when I click any other buttons
digitalWrite(LED, LOW);
digitalWrite(BUZZER, LOW);
}
}
I Learned how to control any component with Bluetooth, it is going to help me to control my final project with Bluetooth.