I have a Switch-Button with which i can switch between two status. In Status 1 i can open the Serial monitor and if i send a ? the Board should try to connect to the given address. After connecting i want to send R. The device will return a N and if i receive the N a LED will blink.
This does not work! The slave device has a LED that symbolizes if the connection is alive or not. The LED is always off. Can anyone help me please?
It looks like you are trying to use Serial to talk to the Serial Monitor AND the bluetooth device. No can do. Only one device can be on the other end of a serial connection - either the PC or the bluetooth device.
But only at the beginning to initiate the communication. After i type '?' the connection between PC and Arduino is closed and the board is calling the sensor. Or is the connection not automatically closed?
After i type '?' the connection between PC and Arduino is closed and the board is calling the sensor.
I don't see anywhere in your code where you are closing the serial connection to the PC.
I don't see where you have a servo or other mechanism that unplugs wires and plugs new ones in.
I don't see where you got the idea that typing something in the Serial Monitor would cause the Arduino to disconnect from the serial port.
What this is leading up to is that you can't use the hardware serial port to communicate with two serial devices, unless you have more than one hardware serial port, like the Mega does.
If you don't, you'll need to use NewSoftSerial to create a software serial port to talk to one of the devices, and connect that device to the correct set of pins.
Another question, how can i use NewSoftSerial with the Bluetooth Module? I thought the Bluetooth Module is only connected with pins 0 and 1 for serial communication. How can i make other pins eligible for bluetooth communication and how can i connect a bluetooth device to a specific pair of pins?
You need to break this problem down into manageable pieces.
Can you get the Arduino to connect to the bluetooth device? Reading serial data and blinking LEDs is extraneous until you can talk to the bluetooth device.
If your bluetooth device connects to the Arduino using the TX/RX pins, then the serial connection to the PC is interfering with the bluetooth connection, and you will never get the bluetooth connection to work.