Hi,
I'm newbie in Arduino and want to learn using BT module with Arduino. I'm using Nano, I connected the BT module through voltage divider to Nano and want to make the LED turn on and off, when sending '0' or '1' according to this tutorial: Arduino and HC-05 Bluetooth Module Tutorial | Android Smartphone & Laptop Control - YouTube
My code:
int ledpin= 7;
int data = 0;
void setup() {
pinMode(ledpin, OUTPUT);
digitalWrite(ledpin, HIGH);
Serial.begin(38400);
Serial.print("Zaciatok programu");
}
void loop()
{
delay(500);
Serial.print("data before serial available= ");
Serial.println(data);
if (Serial.available() > 0)
{
data = Serial.read();
Serial.print("data after serial read= ");
Serial.println(data);
}
if (data == '0')
{
digitalWrite(ledpin, LOW);
Serial.print("data if O= ");
Serial.println(data);
Serial.println("LED OFF");
data = 0;
}
else if (data == '1')
{
digitalWrite(ledpin, HIGH);
Serial.print("data if I= ");
Serial.println(data);
Serial.println("LED OFF");
data = 0;
}
}
Those serialprints are just for debugging.
I'm struggling for a really long time now with this and am frustrated, since it should have been super easy. I spent many and many hours and days trying to figure this out, it probably means it's off my capabilities and I won't be able to deal with arduino stuff, but I don't want to give up.
Problem nr. 1: error 507
I am able to pair the BT module with android phone, but can't connect it to any app designed for serial communication but one: Serial Bluetooth Terminal All other apps give me error 507 unable to connect is the device turned on?
Problem nr 2.: weird values in serial monitor
As I was able to connect to that only one app (led on BT module was on constantly, not blinking) I was glad and tried to send 0 and 1 through the app from my phone.
However the LED on pin 7 did nothing, it stayed on, but I was getting weird values of 'data'. See screenshot.
I tried different baud rates as well.
I am uploading also the wiring, but I am almost sure I have it right, was checking it million times already, but who knows it might be wrong. Not sure if it will be visible fine on photo so added some notes in the photo.
Please help me to solve this, I feel I tried everything, I tried also AT commands, but no response in Serial monitor.
Thank you for all the advices and help, I appreciate your time.



