0% found this document useful (0 votes)
13 views

02_HC05 LM35

The document outlines a project that involves using Bluetooth to control LEDs and display temperature data via an app. It includes a list of required hardware, a circuit diagram, and Arduino code for setting up the Bluetooth communication and controlling the LEDs based on commands received. Additionally, it provides steps for demonstrating the project using a mobile app to connect to the Bluetooth module.

Uploaded by

vinlse181814
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

02_HC05 LM35

The document outlines a project that involves using Bluetooth to control LEDs and display temperature data via an app. It includes a list of required hardware, a circuit diagram, and Arduino code for setting up the Bluetooth communication and controlling the LEDs based on commands received. Additionally, it provides steps for demonstrating the project using a mobile app to connect to the Bluetooth module.

Uploaded by

vinlse181814
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Bluetooth communications

Connect Bluetooth to App Serial Bluetooth Terminal, display temperature in app,


controlled LED on/off.

Hardware Required
 Arduino or Genuino Board
 Module Bluetooth
 Temperature sensor
 LED
 Mobile Phone

Circuit

Arduino Bluetooth Temperature Red LED Yellow Green


Uno HC-05 sensor LM-35 LED LED
D2 TX
D3 RX
D13 Anode
D12 Anode
D11 Anode

1
5V VCC Pin 1 (Vcc)
GND GND Pin 3 (G) Cathode Cathode Cathode
A1 Pin 2 (Out)

Notes:
 D: digital
 A: analog
 GND at the power side

Code
#include <SoftwareSerial.h>
SoftwareSerial bluetooth(2, 3); // RX, TX pins for Bluetooth module

#define RED_LED_PIN 13
#define YELLOW_LED_PIN 12
#define GREEN_LED_PIN 11

#define TEMP_SENSOR_PIN A1

void setup() {
pinMode(RED_LED_PIN, OUTPUT);
pinMode(GREEN_LED_PIN, OUTPUT);
pinMode(YELLOW_LED_PIN, OUTPUT);
Serial.begin(9600);
bluetooth.begin(9600);
}

void loop() {
if (bluetooth.available()) {
char command = bluetooth.read();
if (command == 'R') { // turn on the red LED
digitalWrite(RED_LED_PIN, HIGH);
bluetooth.write("Red LED turned on\n");
} else if (command == 'r') { // turn off the red LED
digitalWrite(RED_LED_PIN, LOW);
bluetooth.write("Red LED turned off\n");
} else if (command == 'Y') { // turn on the yellow LED
digitalWrite(YELLOW_LED_PIN, HIGH);
bluetooth.write(" Yellow LED turned on\n");
} else if (command == 'y') { // turn off the yellow LED
digitalWrite(YELLOW_LED_PIN, LOW);
bluetooth.write("Yellow LED turned off\n");
} else if (command == 'G') { // turn on the green LED
digitalWrite(GREEN_LED_PIN, HIGH);
bluetooth.write("Green LED turned on\n");
} else if (command == 'g') { // turn off the green LED
digitalWrite(GREEN_LED_PIN, LOW);

2
bluetooth.write("Green LED turned off\n");
}
}

int val = analogRead(TEMP_SENSOR_PIN);


float mv = (val / 1023.0) * 5000;
float cel = mv / 10;

bluetooth.print("TEMPRATURE = ");
bluetooth.print(cel);
bluetooth.print("*C");
// debug for checking the temperature sensor
// Serial.println(cel);
bluetooth.println();
delay(1000);
}

Demonstrations
1. Install the Arduino Bluetooth Controller at Google Play

2. Connect the HC-05 using Bluetooth in your device.

3. Type letter R B G or r g b to control LEDs.

You might also like