Mayoogh Girish
Published © CC BY

Arduino Bluetooth Basic Tutorial

Ever thought of controlling any electronic devices with your smart phone? Today I will show how to do it.

BeginnerProtip15 minutes1,087,634
Arduino Bluetooth Basic Tutorial

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
LED (generic)
LED (generic)
×1
Resistor 221 ohm
Resistor 221 ohm
×1
Android device
Android device
×1
HC-05 Bluetooth Module
HC-05 Bluetooth Module
×1

Software apps and online services

LED Controller
Arduino IDE
Arduino IDE

Story

Read more

Schematics

Bluetooth arduino connection schematics

Code

Bluetooh Basic: LED ON OFF

C/C++
This program lets you to control a LED on pin 13 of arduino using a bluetooth module
/* 
 *  Bluetooh Basic: LED ON OFF - Avishkar
 *  Coder - Mayoogh Girish
 *  Website - http://bit.do/Avishkar
 *  Download the App : 
 *  This program lets you to control a LED on pin 13 of arduino using a bluetooth module
 */
char Incoming_value = 0;                //Variable for storing Incoming_value
void setup() 
{
  Serial.begin(9600);         //Sets the data rate in bits per second (baud) for serial data transmission
  pinMode(13, OUTPUT);        //Sets digital pin 13 as output pin
}
void loop()
{
  if(Serial.available() > 0)  
  {
    Incoming_value = Serial.read();      //Read the incoming data and store it into variable Incoming_value
    Serial.print(Incoming_value);        //Print Value of Incoming_value in Serial monitor
    Serial.print("\n");        //New line 
    if(Incoming_value == '1')            //Checks whether value of Incoming_value is equal to 1 
      digitalWrite(13, HIGH);  //If value is 1 then LED turns ON
    else if(Incoming_value == '0')       //Checks whether value of Incoming_value is equal to 0
      digitalWrite(13, LOW);   //If value is 0 then LED turns OFF
  }                            
 
}                 

Arduino Bluetooth Basic Code

Upload Arduino-Bluetooth-Basic.ino sketch to arduino NOTE : Remove Bluetooth module Tx Rx connection before uploading the program.

Credits

Mayoogh Girish

Mayoogh Girish

7 projects • 217 followers
Maker Bloger @ http://mgprojecthub.com/

Comments