Project tutorial
Bluetooth Dialogue with Arduino via HC-05 Module

Bluetooth Dialogue with Arduino via HC-05 Module © GPL3+

Arduino is controlled by Bluetooth dialogue - an LED is remotely turned up or down, a photoresistor value is remotely read.

  • 9 views
  • 0 comments
  • 1 respect

Components and supplies

About this project

Short story here - an Italian detailed description may be downloaded: http://www.cesarebrizio.it/Arduino/HC-05.html

Inspired by an original sketch by TECHBITAR (HAZIM BITAR):

Noteworthy point: once the HC-05 is connected and a serial port is assigned, one can easily use the Serial Monitor of Arduino IDE to send and receive information. In other words, even though the Italian description suggests to use TeraTerm, that software is not strictly needed.

The project is extremely simple, and all that is needed is connecting an Arduino 1 to the HC-05 as illustrated in the fritzing schematics, then get your PC to recognize the HC-05 as an external bluetooth device and assign it a virtual COM port. Since that moment, Arduino can receive and send serial communications, that can be used to send commands and receive readings.

Code

Full Arduino sketchArduino
Controls a photoresistor and a LED via HC-05 bluetooth dialogue
//////////////////////////////////////////////////////////////////////////////////
// REMIXED BY: CESARE BRIZIO FROM AN ORIGINAL BY TECHBITAR (HAZIM BITAR)
// LICENSE: PUBLIC DOMAIN
// DATE: 21/12/2017

char inByte;
int ledPin = 9; // LED on pin 9
int sensorPin = A0;    // input pin for the photoresistor
float sensorValue = 0;  // variable to store the value coming from the sensor

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);
  Serial.println("Type 1 to turn the LED on, 0 to turn it off");
}

void loop() {

  // send data only when you receive data:
  if (Serial.available() > 0) {
    // read the incoming byte:
    inByte = Serial.read();
    // say what you got:
    Serial.print("RECEIVED: ");
    Serial.println(inByte);
    if ( inByte == '0' ) digitalWrite(ledPin, LOW); // if it's a 0 (zero) turn LED off
    if ( inByte == '1' ) digitalWrite(ledPin, HIGH); // if it's a 1 (one) turn LED on
    // read the value from the sensor:
    sensorValue = analogRead(sensorPin);
    Serial.print("Photoresistor reading: ");
    Serial.print(sensorValue);
    Serial.print(" equal to ");
    Serial.print((sensorValue * 5) / 1024);
    Serial.println(" V");
  Serial.println("Type 1 to turn the LED on, 0 to turn it off");
}
}

Schematics

Fritzing schematics
Fritzing schematics including one photoresistor and one LED that can be activated remotely
arduino_con_ricetrasmettitore_bluetooth_yiYw5lekJW.fzz

Comments

Author

Default
CesareBrizio
  • 4 projects
  • 1 follower

Additional contributors

  • Original sketch by HAZIM BITAR (techbitar)

Published on

February 7, 2019

Members who respect this project

PhotoPhoto
See similar projects
you might like

Similar projects you might like

Adding Bluetooth to Your Arduino (+Light Sensor)

Project tutorial by IoTaLabs

  • 4,764 views
  • 0 comments
  • 20 respects

Proyecto: Arduino + Processing + Bluetooth HC-05

Project showcase by victruino

  • 1,425 views
  • 0 comments
  • 3 respects

Arduino 4WD Rover Bluetooth Controlled by an Android device

Project tutorial by AppsByDavideV

  • 1,304 views
  • 0 comments
  • 9 respects

Bluetooth control led with lcd led status display real time.

Project tutorial by Youssef Sabaa

  • 18,994 views
  • 4 comments
  • 37 respects

Bluetooth Mini Car

Project showcase by Hesham

  • 8,676 views
  • 2 comments
  • 30 respects
Add projectSign up / Login