Tell me more ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I am trying to turn ON and OFF a LED with my Android Device through a Bluetooth module (JY-MCU V1.05), I can connect to the module with the key "1234", but when I send a command to the module through the "Bluetooth Terminal" app, there is no respond, no action from the LED.

Here is my installation:

enter image description here

Here is the Arduino code:

char val;         
int ledpin = 13;  

void setup()
{
  pinMode(ledpin = 13, OUTPUT);       
  Serial.begin(115200);               
}

void loop() {
  if( Serial.available() )            
  {                               
  val = Serial.read();                

  if( val == '0' )                    
  {
    digitalWrite(ledpin, LOW);        
    delay(1000);                      
    Serial.println("13 off");         
  }

if( val == '1' )                      
 {
    digitalWrite(ledpin = 13, HIGH);  
    delay(1000);                     
    Serial.println("13 on");          
  }
 }
}

(Also tried with a serial of 9600)

Any idea why I can't communicate with the Arduino ?

share|improve this question
1  
I've just cropped and included your photo, although a schematic would be a lot clearer. You can either use the on-site editor by pressing Ctrl-M or post another image and someone can include it. –  PeterJ Aug 29 at 12:30
 
Thanks, I just added the schema. –  komfushee Aug 29 at 15:52
 
if( Serial.available() ) {;} does not look right... –  Hanno Binder Aug 29 at 15:56
 
Oops, my bad. It was not like that on my original code. But it still does not work. –  komfushee Aug 29 at 17:40

2 Answers

A few problems that I can see are:

  • The JY-MCU appears to be a 3.3V device and you have it connected to VIN which is 5V. Try connecting to the 3V3 line although be aware this will be available only when running from USB power because it's supplied by the FTDI USB chip.

  • Before doing that though I've found references to it not having 5V tolerant serial lines and found a recommendation to use a voltage divider by connecting a 2.2k resistor to ground from the TX line on the Ardunio and a 1k in series between the TX line on the Arduino and the RX line on the module. That was part of a Success Using the JY-MCU (linvor) Bluetooth Module Instructable that you might like to read as well.

  • The default speed appears to be 9600 BPS so stick with that at the moment.

And a few recommendations that are not likely to be your problem but worth changing:

  • You don't have a current limit resistor in series with your LED. See the question Correct formula for LED current-limiting resistor?

  • Only leave ledpin = 13 near the top line where it is declared, remove it from the calls to digitalWrite. It won't make a functional difference it's just a good habit because at the moment if you change the pin you'll have to do it in several spots when not necessary and may forget to.

share|improve this answer
 
OK, I changed everything, but it does not work. I think that the module has burned out with the 5V. I'm gonna buy a new one and try again. Thanks for your help. –  komfushee Aug 30 at 14:01

Do you have the USB plugged into the arduino? I believe (at least with the Uno), pins 0 and 1 are blocked when the USB is plugged in, so I used the SoftSerial library to use any other Digital I/O pins as the Rx and Tx.

share|improve this answer
 
I know that I can't compile with the computer when the module is plugged, so you're right, it may be because of that, I will give it a try and I will tell you. –  komfushee Aug 29 at 19:16
 
You can definitely compile, but the code won't run. –  dawnoflife Aug 29 at 19:32
 
OK, I just tried to add : #include <SoftwareSerial.h> SoftwareSerial mySerial(10, 11); and change every Serial by mySerial, but still nothing. –  komfushee Aug 29 at 20:10
 
You don't have to change every serial to mySerial. In your code serial.println() is printing to the console not to the Tx pin. So, you have to replace your digitalWrite() and digitalRead() commands with mySerial read and write. –  dawnoflife Sep 3 at 19:32

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.