Girlfriend Communicator

Material Required

Schematic

Schematic: Girlfriend Communicator

Code

Download from GitHub

  1. /**********************************************************************
  2. * © 2014 YD Ynvisible, S.A.
  3. *
  4. * FileName:        Girlfriend_Communicator.ino
  5. * Dependencies:    SoftwareSerial.h, CapacitiveSensor.h
  6. * Processor:       ATmega328
  7. * IDE:             Arduino 1.0.5
  8. *
  9. * Description:
  10. * Sending messages to your girlfriend via Bluetooth 4.0 to her smartphone
  11. *
  12. **********************************************************************/
  13.  
  14. #include <CapacitiveSensor.h>
  15. #include <SoftwareSerial.h> //Software Serial Port
  16. #define RxD A0
  17. #define TxD A1
  18. SoftwareSerial blueToothSerial(RxD,TxD);
  19.  
  20. CapacitiveSensor   cs_19_18 = CapacitiveSensor(19,18); // 10M resistor between pins 19 & 18, pin A4 is sensor pin, add a wire and or foil if desired
  21. CapacitiveSensor   cs_19_0 = CapacitiveSensor(19,0);   // 10M resistor between pins 19 & 0, pin 0 is sensor pin, add a wire and or foil if desired
  22. CapacitiveSensor   cs_19_2 = CapacitiveSensor(19,2);   // 10M resistor between pins 19 & 2, pin 2 is sensor pin, add a wire and or foil if desired
  23.  
  24. char a[10] = "#Miss You";
  25. char b[14] = "#Leaving work";
  26. char c[36] = "#I'm Sorry I forgot our anniversary";
  27. char recvChar;
  28. int x=0, touch=0, touch2=0, touch3=0;
  29.  
  30. void setup()
  31. {
  32.   pinMode(RxD, INPUT);
  33.   pinMode(TxD, OUTPUT);
  34.   setupBlueToothConnection();
  35.   cs_19_18.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate
  36.   cs_19_0.set_CS_AutocaL_Millis(0xFFFFFFFF);    
  37.   cs_19_2.set_CS_AutocaL_Millis(0xFFFFFFFF);    
  38. }
  39. void loop()
  40. {
  41.   long start = millis();
  42.   long total1 =  cs_19_18.capacitiveSensor(30);
  43.   long total2 =  cs_19_0.capacitiveSensor(30);    
  44.   long total3 =  cs_19_2.capacitiveSensor(30);    
  45.    
  46.   if(blueToothSerial.available()){            //check if the pipe is free
  47.    
  48.     if(total1>10){
  49.       touch=1;
  50.       cs_19_18.reset_CS_AutoCal();
  51.     }  
  52.     if(touch==1){
  53.       touch=0;
  54.       x++;
  55.       a[10]=char(x+'0');      
  56.       blueToothSerial.print(a);               //sending the whole vector through bluetooth
  57.     }
  58.    
  59.     if(total2>10){
  60.       touch2=1;
  61.       cs_19_0.reset_CS_AutoCal();
  62.     }  
  63.     if(touch2==1){
  64.       touch2=0;
  65.       x++;
  66.       b[14]=char(x+'0');      
  67.       blueToothSerial.print(b);               //sending the whole vector through bluetooth
  68.     }    
  69.    
  70.     if(total3>10){
  71.       touch3=1;
  72.       cs_19_2.reset_CS_AutoCal();
  73.     }  
  74.     if(touch3==1){
  75.       touch3=0;
  76.       x++;
  77.       c[36]=char(x+'0');      
  78.       blueToothSerial.print(c);               //sending the whole vector through bluetooth
  79.     }    
  80.   }
  81. }  
  82.  
  83. void setupBlueToothConnection(){
  84.   blueToothSerial.begin(9600); //Set BluetoothBee BaudRate to default baud rate 9600
  85.   delay(10); // This delay is required.
  86.   blueToothSerial.print("AT+RENEW"); //Restore all setup value to factory setup
  87.   delay(10);  // This delay is required.
  88.   blueToothSerial.print("AT+ROLE0"); //make it a slave  
  89.   delay(10);  // This delay is required.
  90. }
  91. //END
/**********************************************************************
* © 2014 YD Ynvisible, S.A.
*
* FileName:        Girlfriend_Communicator.ino
* Dependencies:    SoftwareSerial.h, CapacitiveSensor.h
* Processor:       ATmega328
* IDE:             Arduino 1.0.5
*
* Description:
* Sending messages to your girlfriend via Bluetooth 4.0 to her smartphone
* 
**********************************************************************/
#include <CapacitiveSensor.h>
#include <SoftwareSerial.h> //Software Serial Port
#define RxD A0
#define TxD A1
SoftwareSerial blueToothSerial(RxD,TxD);
CapacitiveSensor   cs_19_18 = CapacitiveSensor(19,18); // 10M resistor between pins 19 & 18, pin A4 is sensor pin, add a wire and or foil if desired
CapacitiveSensor   cs_19_0 = CapacitiveSensor(19,0);   // 10M resistor between pins 19 & 0, pin 0 is sensor pin, add a wire and or foil if desired
CapacitiveSensor   cs_19_2 = CapacitiveSensor(19,2);   // 10M resistor between pins 19 & 2, pin 2 is sensor pin, add a wire and or foil if desired
char a[10] = "#Miss You";
char b[14] = "#Leaving work";
char c[36] = "#I'm Sorry I forgot our anniversary";
char recvChar;
int x=0, touch=0, touch2=0, touch3=0;
void setup()
{
  pinMode(RxD, INPUT);
  pinMode(TxD, OUTPUT);
  setupBlueToothConnection();
  cs_19_18.set_CS_AutocaL_Millis(0xFFFFFFFF);     // turn off autocalibrate
  cs_19_0.set_CS_AutocaL_Millis(0xFFFFFFFF);     
  cs_19_2.set_CS_AutocaL_Millis(0xFFFFFFFF);    
}
void loop()
{
  long start = millis(); 
  long total1 =  cs_19_18.capacitiveSensor(30);
  long total2 =  cs_19_0.capacitiveSensor(30);    
  long total3 =  cs_19_2.capacitiveSensor(30);    
  if(blueToothSerial.available()){            //check if the pipe is free
    if(total1>10){
      touch=1;
      cs_19_18.reset_CS_AutoCal();
    }   
    if(touch==1){
      touch=0;
      x++;
      a[10]=char(x+'0');      
      blueToothSerial.print(a);               //sending the whole vector through bluetooth
    }
    if(total2>10){
      touch2=1;
      cs_19_0.reset_CS_AutoCal();
    }   
    if(touch2==1){
      touch2=0;
      x++;
      b[14]=char(x+'0');      
      blueToothSerial.print(b);               //sending the whole vector through bluetooth
    }     
    if(total3>10){
      touch3=1;
      cs_19_2.reset_CS_AutoCal();
    }   
    if(touch3==1){
      touch3=0;
      x++;
      c[36]=char(x+'0');      
      blueToothSerial.print(c);               //sending the whole vector through bluetooth
    }     
  }
}  
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