Bluetooth Fan

Bluetooth Fan

Material Required

  • Printoo Core
  • DC Motors Drivers & one Motor (Fan)
  • Bluetooth 4.0 Module
  • LiPo battery
  • Smartphone

Schematic

Schematic: Bluetooth Fan

Schematic: Bluetooth Fan

Code

Download from GitHub

  1. /**********************************************************************
  2. * © 2014 YD Ynvisible, S.A.
  3. *
  4. * FileName: Bluetooth_Fan.ino
  5. * Dependencies: SoftwareSerial.h
  6. * Processor: ATmega328
  7. * IDE: Arduino 1.0.5
  8. *
  9. * Description:
  10. * Fan activated by a smartphone via Bluetooth 4.0
  11. * Sending '#' activates the fan
  12. **********************************************************************/
  13.  
  14. #include <SoftwareSerial.h> //Software Serial Port
  15. #define RxD 11 //Bluetooth TX=Core RX
  16. #define TxD 12 //Bluetooth RX=Core TX
  17.  
  18. int motor1_pwm=6; //Motor1 PWM
  19. int motor1_dir=7; //Motor1 Direction
  20. char recvChar=0;
  21.  
  22. SoftwareSerial blueToothSerial(RxD,TxD);
  23.  
  24. void setup()
  25. {
  26.  pinMode(RxD, INPUT);
  27.  pinMode(TxD, OUTPUT);
  28.  pinMode(motor1_pwm, OUTPUT);
  29.  pinMode(motor1_dir, OUTPUT);
  30.  digitalWrite(motor1_pwm,LOW);
  31.  digitalWrite(motor1_dir,LOW);
  32.  
  33.  setupBlueToothConnection();
  34. }
  35. void loop()
  36. {
  37.  if(blueToothSerial.available()){ //check if the pipe is free
  38.  recvChar = blueToothSerial.read();
  39.  if(recvChar=='#'){
  40.  analogWrite(motor1_pwm,40);
  41.  digitalWrite(motor1_dir,LOW);
  42.  }
  43.  else{
  44.  analogWrite(motor1_pwm,0);
  45.  digitalWrite(motor1_dir,LOW);
  46.  }
  47.  }
  48. }
  49.  
  50. void setupBlueToothConnection(){
  51.  blueToothSerial.begin(9600); //Set BluetoothBee BaudRate to default baud rate 9600
  52.  delay(10); // This delay is required.
  53.  blueToothSerial.print("AT+RENEW"); //Restore all setup value to factory setup
  54.  delay(10); // This delay is required.
  55.  blueToothSerial.print("AT+ROLE0"); //make it a slave
  56.  delay(10); // This delay is required.
  57. }
  58. //END
/**********************************************************************
* © 2014 YD Ynvisible, S.A.
*
* FileName: Bluetooth_Fan.ino
* Dependencies: SoftwareSerial.h
* Processor: ATmega328
* IDE: Arduino 1.0.5
*
* Description:
* Fan activated by a smartphone via Bluetooth 4.0
* Sending '#' activates the fan
**********************************************************************/

#include <SoftwareSerial.h> //Software Serial Port
#define RxD 11 //Bluetooth TX=Core RX
#define TxD 12 //Bluetooth RX=Core TX

int motor1_pwm=6; //Motor1 PWM
int motor1_dir=7; //Motor1 Direction
char recvChar=0;
 
SoftwareSerial blueToothSerial(RxD,TxD);

void setup()
{
 pinMode(RxD, INPUT);
 pinMode(TxD, OUTPUT);
 pinMode(motor1_pwm, OUTPUT); 
 pinMode(motor1_dir, OUTPUT); 
 digitalWrite(motor1_pwm,LOW);
 digitalWrite(motor1_dir,LOW);
 
 setupBlueToothConnection(); 
}
void loop()
{
 if(blueToothSerial.available()){ //check if the pipe is free
 recvChar = blueToothSerial.read();
 if(recvChar=='#'){
 analogWrite(motor1_pwm,40);
 digitalWrite(motor1_dir,LOW);
 }
 else{
 analogWrite(motor1_pwm,0); 
 digitalWrite(motor1_dir,LOW); 
 } 
 }
} 
 
void setupBlueToothConnection(){
 blueToothSerial.begin(9600); //Set BluetoothBee BaudRate to default baud rate 9600
 delay(10); // This delay is required.
 blueToothSerial.print("AT+RENEW"); //Restore all setup value to factory setup
 delay(10); // This delay is required.
 blueToothSerial.print("AT+ROLE0"); //make it a slave 
 delay(10); // This delay is required.
}
//END