Devices & Components
Arduino Uno Rev3
Breadboard (generic)
Jumper wires (generic)
5 mm LED: Green
Resistor 220 ohm
HC-05 Bluetooth Module
5 mm LED: Red
Project description
Code
Code
c_cpp
The project code
1#include <SoftwareSerial.h> 2String value; 3int TxD = 11; 4int RxD = 10; 5int servoposition; 6SoftwareSerial bluetooth(TxD, RxD); 7 8void setup() { 9 pinMode(2, OUTPUT); 10 pinMode(3, OUTPUT); 11 Serial.begin(9600); // start serial communication at 9600bps 12 bluetooth.begin(9600); 13} 14 15void loop() { 16 Serial.println(value); 17 if (bluetooth.available()) 18 { 19 value = bluetooth.readString(); 20 21 if (value == "all LED turn on"){ 22 digitalWrite(2, HIGH); 23 digitalWrite(3, HIGH); 24 } 25 26 if (value == "all LED turn off"){ 27 digitalWrite(2, LOW); 28 digitalWrite(3, LOW); 29 } 30 31 if (value == "turn on Red LED"){ 32 digitalWrite(2, HIGH); 33 } 34 35 if (value == "turn on green LED"){ 36 digitalWrite(3, HIGH); 37 } 38 39 if (value == "turn off red LED"){ 40 digitalWrite(2, LOW); 41 } 42 43 if (value == "turn off green LED"){ 44 digitalWrite(3, LOW); 45 } 46 47 } 48 49} 50
Code
c_cpp
The project code
1#include <SoftwareSerial.h> 2String value; 3int TxD = 11; 4int RxD = 10; 5int servoposition; 6SoftwareSerial bluetooth(TxD, RxD); 7 8void setup() { 9 pinMode(2, OUTPUT); 10 pinMode(3, OUTPUT); 11 Serial.begin(9600); // start serial communication at 9600bps 12 bluetooth.begin(9600); 13} 14 15void loop() { 16 Serial.println(value); 17 if (bluetooth.available()) 18 { 19 value = bluetooth.readString(); 20 21 if (value == "all LED turn on"){ 22 digitalWrite(2, HIGH); 23 digitalWrite(3, HIGH); 24 } 25 26 if (value == "all LED turn off"){ 27 digitalWrite(2, LOW); 28 digitalWrite(3, LOW); 29 } 30 31 if (value == "turn on Red LED"){ 32 digitalWrite(2, HIGH); 33 } 34 35 if (value == "turn on green LED"){ 36 digitalWrite(3, HIGH); 37 } 38 39 if (value == "turn off red LED"){ 40 digitalWrite(2, LOW); 41 } 42 43 if (value == "turn off green LED"){ 44 digitalWrite(3, LOW); 45 } 46 47 } 48 49} 50
Downloadable files
Schematic design
The project circuit diagram
Schematic design

Comments
Only logged in users can leave comments