Hi. I want to control LED by android app. But when I verify the code an error is displayed. this is my code:
#include "BluetoothSerial.h"
BluetoothSerial SerialBT;
const int ledpin = 2;
void setup() {
SerialBT.begin("ESP8266-Bluetooth"); //Bluetooth device name
pinMode(ledpin, OUTPUT);
}
void loop() {
//Read character
if (SerialBT.available()) {
char c = SerialBT.read();
if(c=='1'){
digitalWrite(ledpin,HIGH);
}
else if (c=='0'){
digitalWrite(ledpin,LOW);
}
}
}
And this is the error message:
sketch_aug07b:3:17: error: no matching function for call to 'BluetoothSerial::BluetoothSerial()'
BluetoothSerial SerialBT;
^~~~~~~~
In file included from C:\Users\javadi\Documents\Arduino\sketch_aug07b\sketch_aug07b.ino:1:0:
C:\Users\javadi\Documents\Arduino\libraries\BluetoothSerial-1.1.0\src/BluetoothSerial.h:42:5: note: candidate: BluetoothSerial::BluetoothSerial(HardwareSerial&, bool)
BluetoothSerial(HardwareSerial& serial, bool verbose = true);
^~~~~~~~~~~~~~~
C:\Users\javadi\Documents\Arduino\libraries\BluetoothSerial-1.1.0\src/BluetoothSerial.h:42:5: note: candidate expects 2 arguments, 0 provided
C:\Users\javadi\Documents\Arduino\libraries\BluetoothSerial-1.1.0\src/BluetoothSerial.h:17:7: note: candidate: constexpr BluetoothSerial::BluetoothSerial(const BluetoothSerial&)
class BluetoothSerial {
^~~~~~~~~~~~~~~
C:\Users\javadi\Documents\Arduino\libraries\BluetoothSerial-1.1.0\src/BluetoothSerial.h:17:7: note: candidate expects 1 argument, 0 provided
C:\Users\javadi\Documents\Arduino\libraries\BluetoothSerial-1.1.0\src/BluetoothSerial.h:17:7: note: candidate: constexpr BluetoothSerial::BluetoothSerial(BluetoothSerial&&)
C:\Users\javadi\Documents\Arduino\libraries\BluetoothSerial-1.1.0\src/BluetoothSerial.h:17:7: note: candidate expects 1 argument, 0 provided
C:\Users\javadi\Documents\Arduino\sketch_aug07b\sketch_aug07b.ino: In function 'void loop()':
sketch_aug07b:14:14: error: 'class BluetoothSerial' has no member named 'available'
if (SerialBT.available()) {
^~~~~~~~~
sketch_aug07b:15:21: error: 'class BluetoothSerial' has no member named 'read'
char c = SerialBT.read();
^~~~
exit status 1
no matching function for call to 'BluetoothSerial::BluetoothSerial()'