Hey everyone, Im trying to get fimilar with bluetooth on the arduino and im having a small problem with my coding as im not very strong in the field, the main problem im having is getting a push button to relay a message back to my phone when pressed. Id appreciate it if anyone could help me with this.
#include <SoftwareSerial.h>
#include <LiquidCrystal.h> //Include the library that enables you to use the LCD
LiquidCrystal lcd(2,3,4,5,6,7);//Declare that your LCD is connected to pins 2,3,4,5,6 & 7 on your Arduino
SoftwareSerial BTserial(1, 0);
int switchState = 0;
void setup()
{
lcd.begin(16,2);
Serial.begin(9600);
Serial.println("Enter AT commands:");
pinMode(8,INPUT);
// HC-06 default serial speed is 9600
BTserial.begin(9600);
}
void loop()
{
// Keep reading from HC-06 and send to Arduino Serial Monitor
if (BTserial.available())
{
Serial.write(BTserial.read());
}
// Keep reading from Arduino Serial Monitor and send to HC-06
if (Serial.available())
{
BTserial.write(Serial.read());
lcd.write(Serial.read());
}
switchState = digitalRead(8);
if (switchState == HIGH)
{
BTserial.write("hello");
}
}