hi i need help, i am setting up a control for the central locking in my car, my desire is to us my mobile to control it via bluetooth, i am trying to build in a password type security setup, ie phone transmits password that arduino recieves then if correct either locks or unlocks the car, however the problem i am having is that arduino only seems to recieve gibberish from the phone, (among others but the most pressing is the gibberish), i have had the phone and arduino communication via the amarino test code as well as other examples available out there
this is the bluetooth unit,
http://www.ebay.com/itm/160879748403?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1439.l2649
and i am using the mega2680 board, the phone is a galaxy s2, using the amarino app
i also intend (in the future) to sort out a custom app as the remote locking is only 1 feature i wish to use the arduino for in the car
i would appreciate help or guidance as to where to find out more info on doing this, or if its my code or the application from the phone that is causing my problem
the code is as follows
#define BUFFERSIZE 127
uint8_t inBuffer[BUFFERSIZE];
int ledpin = 13;
int inLength; // length of data in the buffer
int unlockpin = 22;//unlock relay pin
int lockpin = 23;// locking relay pin
int numLoop = 0; // number of times we looped
char unlocker = 'Apassword1'; //unlock code
char locker = 'Apassword2'; //lock code
void setup() {
Serial.begin(9600);
pinMode(ledpin, OUTPUT);
}
void unlock(){
digitalWrite(unlockpin, HIGH);
delay(1000);
digitalWrite(unlockpin, LOW);
delay(1000);
Serial.print("welcome");}
void lock(){
digitalWrite(lockpin, HIGH);
delay(1000);
digitalWrite(lockpin, LOW);
delay(1000);
Serial.print("goodbye");
}
void loop () {
// read string if available
if (Serial.available()) {
inLength = 0;
while (Serial.available()) {
inBuffer[ inLength] = Serial.read();
if (inBuffer[ inLength] == unlocker){ //compares data recieved and if correct unlocks car
unlock();
}
if (inBuffer[ inLength] == locker){ //compares data recieved and if correct locks car
lock();
}
inLength++;
if (inLength >= BUFFERSIZE)
break;
}
Serial.print("Arduino received: ");
Serial.write(inBuffer ,inLength);
Serial.println();
}
// blink the led and send a number
//digitalWrite(ledPin, HIGH); // set the LED on
delay(1000); // wait a bit
Serial.println(numLoop);
//digitalWrite(ledPin, LOW); // set the LED off
//delay(1000);
numLoop++;
}