Trouble with Bluetooth (JY-MCU)

I'm trying to get this Bluetooth module to work however every time I try to use any apps to turn on an led or do anything it does nothing (the Bluetooth module's led does go from blinking to solid when I connect it with the apps so I know that isn't the problem)

SETUP~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Arduino GND: led negative leg Arduino pin 13: led Arduino pin 0 (RX): TXD on bluetooth Arduino pin 1 (TX): RXD on bluetooth Arduino GND: GND pin on bluetooth module Arduino 5V: VCC pin on bluetooth module

CODE: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ int led = 13; char data = 0; void setup() { Serial.begin(9600); pinMode(led, OUTPUT); } void loop() { if(Serial.available() > 0) { data = Serial.read(); Serial.print(data); Serial.print("\n"); if(data == '1') digitalWrite(led, HIGH); else if(data == '0') digitalWrite(led, LOW); } }


I've been using several apps for this to try to get it to work but for this example lets say im trying to get it to work on "Bluetooth Terminal HC-05" (An image of it is attached to this post)

![Screenshot_20171112-183607[1].png|720x1280](//discourse-cloud-file-uploads.s3.dualstack.us-west-2.amazonaws.com/arduino/original/3X/8/d/8d34a212bc82194609cd8a213c08707852974bda.png)

I have an update, the serial monitor prints ⸮ whenever I press "Led on" for some reason instead of printing 1

My Bluetooth module isn't working and im pretty sure it has to do with the code because when I connect the module to any apps it works and the light stops blinking however the data that gets sent over to my serial monitor just says "?" it gives me a question mark instead of a 1 or a 0

My Bluetooth module isn't working and im pretty sure it has to do with the code because when I connect the module to any apps it works and the light stops blinking however the data that gets sent over to my serial monitor just says "?" it gives me a question mark instead of a 1 or a 0

int led = 13; char data = 0; void setup() { Serial.begin(9600); pinMode(led, OUTPUT); } void loop() { if(Serial.available() > 0) { data = Serial.read(); Serial.print(data); Serial.print("\n"); if(data == '1') digitalWrite(led, HIGH); else if(data == '0') digitalWrite(led, LOW); } }

CraftingStudio: I have an update, the serial monitor prints ⸮ whenever I press "Led on" for some reason instead of printing 1

Press "Led on" on what?

on the app (its supposed to send a 1 when I push it) led off sends a 0

CraftingStudio: when I connect the module to any apps it works and the light stops blinking

Al that does is prove the connection between Android and Bluetooth. There may still be procedural problems, between Bluetooth and Arduino - some dumb mistake you will only make once.

Your code cannot use serial monitor, the Serial.print should just be regurgitation back to Android and you just get to watch with the monitor.

You might find the following background notes useful

http://homepages.ihug.com.au/~npyner/Arduino/GUIDE_2BT.pdf http://homepages.ihug.com.au/~npyner/Arduino/BT_2_WAY.ino

@CraftingStudio, do not cross-post. Threads merged.

Serial.print(data); Serial.print("\n");

implies (to me at least) you are using the serial monitor at the same time? If you are this will be interfering with the Bluetooth.

While debugging it may be better to use software serial for the Bluetooth module then you can use the serial monitor for printing out the received data etc.