HC-06 does not work on arduino MEGA

HEy GUYS,
i have arduino uno and i send data from my PC C # aplication to HC-06 modul conected to arduino UNO. everything is working. the first i tried blink LED.all well. but if i do the same with ARDUINO MEGA its not working.IDont Know why. When i execute C# aplication the red light on HC-06 STOP bliking, its good but thats all. nothing else.
thank you for help

You will have to show your code. Also make a drawing of how things are connected and post a photo of the drawing.

I would expect the Mega to be easier to use as it has 4 hardware serial ports.

...R

I have everthing like here....everything. but with ARDUINO MEGA
AND the code of C# app is in windows form aplication.
:
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();

}

private void button1_Click(object sender, EventArgs e)
{
this.serialPort1.Write("E");

}

private void Form1_Load(object sender, EventArgs e)
{
this.serialPort1.Open();
CheckForIllegalCrossThreadCalls = false;
}

private void Form1_FormClosed(object sender, FormClosedEventArgs e)
{
this.serialPort1.Close();
}

private void button2_Click(object sender, EventArgs e)
{
this.serialPort1.Write("A");
}

private void serialPort1_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
// if(this.serialPort1.ReadExisting()=="")
}

private void timer1_Tick(object sender, EventArgs e)
{
this.tbOutput.Text = "";
}

this code for arduino exactly:
#include <SoftwareSerial.h>
SoftwareSerial mySerial(4, 2);
int ledpin=11;
char inChar;
void setup() {
Serial.begin(9600);
Serial.println(“Type AT commands!”);
pinMode(ledpin,OUTPUT);
mySerial.begin(9600);
}

void loop() {
if (mySerial.available()) {
//digitalWrite(ledpin,HIGH);
while(mySerial.available()){
inChar= (char)mySerial.read();
if(inChar == ‘E’)digitalWrite(ledpin,HIGH);
if(inChar == ‘A’)digitalWrite(ledpin,LOW);
}
}
if (Serial.available()){
delay(100); // The delay is necessary to get this working!
mySerial.write(Serial.read());
}
}

Smrtozrut:
i send data from my PC C # aplication to HC-06 modul conected to arduino UNO. everything is working.

This is most likely some silly procedural problem that is easily fixed. There is no need to show the code, all you need do is do on the Mega exactly the same as you did on Uno.

When i execute C# aplication the red light on HC-06 STOP bliking, its good but thats all. nothing else.

This is not very helpful and not necessarily good either.

What does the LED do when it stops blinking? Does it go continuous? The normal procedure is that the LED stops blinking when a connection is made with the other bluetooth device and goes continuous. It has nothing to do with the C# application, whatever that may be, and Arduino does not even need to be connected to bluetooth.

If what you say happened really did happen, it's bad, not good, and best guess is that you have a serious power problem. The good side is that there may be nothing wrong with bluetooth, or the code, but the wiring might be suss.

Despite the Uno being kosher, a much better test for Arduino bluetooth is to simply send data to a standard terminal on PC or, even better, an Android phone. 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

Smrtozrut:
this code for arduino exactly:

You don't need to use SoftwareSerial on a Mega. Just connect your Bluetooth to pins 18 and 19 and use Serial1

...R

Robin2:
You don't need to use SoftwareSerial on a Mega. Just connect your Bluetooth to pins 18 and 19 and use Serial1

...R

I tried it before and it was the same. BUUUUUUUUUT, without SoftwareSerial in my arduino code i was using just "SERIAL." and when you wrote Serial1 i tried it and it start working so YEAH i v got it and i fixed it thank to you...
Thank you all guys...
BTW how it is possible?

The HC-06 works on the arduino mega. I had posted the arduino HC-06 tutorial on my website and for some reason the example code i had given was not working. The reason was because i was using a while(Serial.available()) loop instead of a while(Serial.available()>0) loop. Once i changed that the HC-06 started working with the arduino mega.

You can see the tutorial here: www.arduino-hacks.com/adding-bluetooth-capability-project-arduino-hc-06/

I have noted the required changes just below the code in the tutorial.

Thanks

Smrtozrut:
i was using just "SERIAL." and when you wrote Serial1 i tried it and it start working so YEAH i v got it and i fixed it thank to you...

On a Mega (as on an Uno) Serial is used to communicate with the PC over the USB cable. Serial1, Serial2 and Serial3 are for the other 3 hardware USARTs

...R

thank you all guys:) i appretiated that you helped me:)