Hey guys.I need help with a safe operated via bluetooth.I'm using the arduino UNO with the bluetooth bee shield.This what I got so far.
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// serial port
long DATARATE = 38400; // default data rate for BT Bee
char inChar = 0;
int LED = 13; // Pin 13 is connected to a LED on many Arduinos
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
Serial.begin(DATARATE);
// bluetooth bee setup
Serial.print("\r\n+STWMOD=0\r\n"); // set to slave
delay(1000);
Serial.print("\r\n+STNA=DSC\r\n"); // DSC = digital setting circles
delay(1000);
Serial.print("\r\n+STAUTO=0\r\n"); // don't permit auto-connect
delay(1000);
Serial.print("\r\n+STOAUT=1\r\n"); // existing default
delay(1000);
Serial.print("\r\n +STPIN=0000\r\n"); // existing default
delay(2000); // required
// initiate BTBee connection
Serial.print("\r\n+INQ=1\r\n");
delay(2000); // wait for pairing
pinMode(LED, OUTPUT);
}
void loop() {
lcd.setCursor(0, 1);
// test app:
// wait for character,
// a returns message, h=led on, l=led off
if (Serial.available()) {
inChar = Serial.read();
if (inChar == 'a') {
Serial.print("connected"); // test return connection
lcd.print("connected!");
}
if (inChar == 'h') {
digitalWrite(LED, HIGH); // on
lcd.print("LED ON!");}
if (inChar == 'l') {
digitalWrite(LED, LOW); // off
lcd.print("LED OFF!");
}
}
}
As you can see this is a test program when a 'h' is sent a LED comes on,when a "l' is sent the comes off and 'a' is test to test the connection.Now the problem is changing it so I can test for a 4 digit password with only two outcomes.If the password= serial read then LED on and if not LED off.
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// serial port
long DATARATE = 38400; // default data rate for BT Bee
char inChar = 0;
int LED = 13; // Pin 13 is connected to a LED on many Arduinos
void setup() {
// set up the LCD's number of columns and rows:
lcd.begin(16, 2);
Serial.begin(DATARATE);
// bluetooth bee setup
Serial.print("\r\n+STWMOD=0\r\n"); // set to slave
delay(1000);
Serial.print("\r\n+STNA=DSC\r\n"); // DSC = digital setting circles
delay(1000);
Serial.print("\r\n+STAUTO=0\r\n"); // don't permit auto-connect
delay(1000);
Serial.print("\r\n+STOAUT=1\r\n"); // existing default
delay(1000);
Serial.print("\r\n +STPIN=0000\r\n"); // existing default
delay(2000); // required
// initiate BTBee connection
Serial.print("\r\n+INQ=1\r\n");
delay(2000); // wait for pairing
pinMode(LED, OUTPUT);
}
void loop() {
lcd.setCursor(0, 1);
// test app:
// wait for character,
// a returns message, h=led on, l=led off
if (Serial.available()) {
inChar = Serial.read();
if (inChar == 'a') {
Serial.print("connected"); // test return connection
lcd.print("connected!");
}
if (inChar == 'h') {
digitalWrite(LED, HIGH); // on
lcd.print("LED ON!");}
if (inChar == 'l') {
digitalWrite(LED, LOW); // off
lcd.print("LED OFF!");
}
}
}
As you can see this is a test program when a 'h' is sent a LED comes on,when a "l' is sent the comes off and 'a' is test to test the connection.Now the problem is changing it so I can test for a 4 digit password with only two outcomes.If the password= serial read then LED on and if not LED off.