Arduino controls devices via Bluetooth over Android






Arduino controls devices via Bluetooth over Android


Hardware needed
  you will need for this project a Bluetooth Module and an Arduino Microcontroller Board with Relay Output Board

  •           Serial Port Bluetooth Module( TTL )
  •           Arduino Microcontroller Board (ET-BASEAVR EASY328 ) Arduino Compatible Board
  •           8 channel Output Relay Board
Wiring Diagram

Output 1 to Pin 4 ( Arduino Board )
Output 2 to Pin 5
Output 3 to Pin 6
Output 4 to Pin 7
Output 5 to Pin 8
Output 6 to Pin 9
Output 7 to Pin 10
Output 8 to Pin 11
Bluetooth Module Tx to  Pin 0
Bluetooth Module Rx to  Pin 1




Download Micro controller firmware

For Arduino 1.00+
For Arduino 1.00+ ( Active Low Relay Output )
Arduino Microcontroller Board Source code

#define LED_PIN1  4
#define LED_PIN2  5
#define LED_PIN3  6
#define LED_PIN4  7

#define LED_PIN5  8
#define LED_PIN6  9
#define LED_PIN7  10
#define LED_PIN8  11

int firstSensor = 0;         // first analog sensor
int secondSensor = 0;    // second analog sensor
int thirdSensor = 0;        // digital sensor
int inByte = 0;               // incoming serial byte
boolean status_unlock;
boolean status_bluetooth;

long interval = 1000;           // interval at which to blink (milliseconds)
long previousMillis = 0;        // will store last time LED was update
int minite,sec;


void setup()
{
  // start serial port at 9600 bps:
  Serial.begin(9600);
  //pinMode(2, INPUT);   // digital sensor is on digital pin 2
  //establishContact();    // send a byte to establish contact until receiver responds
 
  pinMode(LED_PIN1, OUTPUT);
  pinMode(LED_PIN2, OUTPUT);
  pinMode(LED_PIN3, OUTPUT);
  pinMode(LED_PIN4, OUTPUT);

  pinMode(LED_PIN5, OUTPUT);
  pinMode(LED_PIN6, OUTPUT);
  pinMode(LED_PIN7, OUTPUT);
  pinMode(LED_PIN8, OUTPUT);
 
  digitalWrite(LED_PIN1, LOW);  // switch off LED
  digitalWrite(LED_PIN2, LOW);  // switch off LED
  digitalWrite(LED_PIN3, LOW);  // switch off LED
  digitalWrite(LED_PIN4, LOW);  // switch off LED
   
  digitalWrite(LED_PIN5, LOW);  // switch off LED
  digitalWrite(LED_PIN6, LOW);  // switch off LED
  digitalWrite(LED_PIN7, LOW);  // switch off LED
  digitalWrite(LED_PIN8, LOW);  // switch off LED
 
  status_bluetooth = true;
  status_unlock = false;
  sec = 0;
}

void loop()
{
  if (Serial.available() > 0) {  
      
    inByte = Serial.read();                      // get incoming byte: 

    if(inByte == 'A'){   
      digitalWrite(LED_PIN1, HIGH);        // switch on LED
      Serial.print('A', BYTE);                    // send a char
      //delay(800);
      digitalWrite(LED_PIN1, LOW);        // switch off LED
      status_unlock = false;
      inByte = 0;    
    }
   
    if(inByte == 'a'){   
      digitalWrite(LED_PIN2, HIGH);        // switch on LED
      Serial.print('a', BYTE);                    // send a char
      //delay(800);
      digitalWrite(LED_PIN2, LOW);        // switch off LED
     
      status_unlock = true;
      sec = 0;
      inByte = 0;    
    }
   
    if(inByte == 'B'){   
      digitalWrite(LED_PIN3, HIGH);        // switch on LED
      Serial.print('B', BYTE);                    // send a char
      inByte = 0;    
    }
   
    if(inByte == 'b'){   
      digitalWrite(LED_PIN3, LOW);        // switch off LED
      Serial.print('b', BYTE);                   // send a char
      inByte = 0;    
    }
   
    if(inByte == 'C'){   
      digitalWrite(LED_PIN4, HIGH);        // switch on LED
      Serial.print('C', BYTE);                    // send a char
      inByte = 0;    
    }
   
    if(inByte == 'c'){   
      digitalWrite(LED_PIN4, LOW);        // switch off LED
      Serial.print('c', BYTE);                    // send a char
      inByte = 0;    
    }
   
    if(inByte == 'D'){   
      digitalWrite(LED_PIN5, HIGH);        // switch on LED
      Serial.print('D', BYTE);                    // send a char
      inByte = 0;    
    }
   
    if(inByte == 'd'){   
      digitalWrite(LED_PIN5, LOW);        // switch off LED
      Serial.print('d', BYTE);                   // send a char
      inByte = 0;    
    }
   
    if(inByte == 'E'){   
      digitalWrite(LED_PIN6, HIGH);        // switch on LED
      Serial.print('E', BYTE);                    // send a char
      inByte = 0;    
    }
   
    if(inByte == 'e'){   
      digitalWrite(LED_PIN6, LOW);        // switch off LED
      Serial.print('e', BYTE);                   // send a char
      inByte = 0;    
    }
   
    if(inByte == 'F'){   
      digitalWrite(LED_PIN7, HIGH);        // switch on LED
      Serial.print('F', BYTE);                    // send a char
      inByte = 0;    
    }
   
    if(inByte == 'f'){   
      digitalWrite(LED_PIN7, LOW);        // switch off LED
      Serial.print('f', BYTE);                    // send a char
      inByte = 0;    
    }
   
    if(inByte == 'G'){   
      digitalWrite(LED_PIN8, HIGH);        // switch on LED
      Serial.print('G', BYTE);                    // send a char
      inByte = 0;    
    }
   
    if(inByte == 'g'){   
      digitalWrite(LED_PIN8, LOW);        // switch off LED
      Serial.print('g', BYTE);                   // send a char
      inByte = 0;    
    }   
   
    if(inByte == 'S'){   
     
      Serial.print('S', BYTE);                  // send a char
      status_bluetooth = true;
      sec = 0;
         
    }   
  } // if(Serial
 
  /*
  unsigned long currentMillis = millis();
     
              if(currentMillis - previousMillis > interval) {           
                previousMillis = currentMillis;         // save the last time you blinked the LED
               
                sec++;
               
                if(status_unlock==true){
               
                  if(sec== 11){
               
                      digitalWrite(LED_PIN1, HIGH);        // switch on LED
               
                      delay(800);
                      digitalWrite(LED_PIN1, LOW);        // switch off LED
               
                      status_unlock = false;                 
                      sec = 0;
                  }
                }
                else sec = 0;               
               
              }
 
 */
   
} //Loop

void establishContact() {
  while (Serial.available() <= 0) {
    Serial.print('.', BYTE);                   // send a capital A
    delay(500);
  }
}



Android Bluetooth Control Device

Android Bluetooth Control Device
 
Android Bluetooth Control Device Application allows you to control various electrical devices up to 8 devices and independently. Use your Android phone's Bluetooth to  remote control your devices with Bluetooth Receiver hardware Device.

The program features.
- you can control up to  8 devices.
- Can set Timer to switch ON / OFF the device and show the time.(the timer can be set to 1 minute, 15 minutes, 30 minutes, 1 hour, 2 hours, 4 hours).
- Can be used with Receiving device.
Designed for the Android version 4 and a screen resolution of 480 x 800 (WVGA).
Freeware with AD (free software)

A test transmission via Bluetooth.
Device1 ON sent “A” , Device1 OFF sent “a”
Device2 ON sent “B” , Device2 OFF sent “b”
Device3 ON sent “C” , Device3 OFF sent “c”
Device4 ON sent “D” , Device4 OFF sent “d”
Device5 ON sent “E” , Device5 OFF sent “e”
Device6 ON sent “F” , Device6 OFF sent “f”
Device7 ON sent “G” , Device7 OFF sent “g”
Device8 ON sent “H” , Device8 OFF sent “h” 
keywords:
bluetooth  receiver
arduino
arduino microcontroller
arduino android
android

Filled Under:

0 commentaires:

Post a Comment