user25568: I am trying to both send and receive data using bluetooth module.
Receiving data works fine with this code:
void setup() { 
    Serial1.begin(9600);
    Serial.begin(9600);
} 

void loop() { 
    if (Serial1.available()) {
        Serial.println(Serial1.read());
    }

    delay(20);                          
}

But I cannot send any data. This is what I am doing:
void loop() { 
    if (Serial1.available()) {
       Serial.println(Serial1.read());
    }

    delay(20);

    if (digitalRead(bluetoothInput) == HIGH) {
        Serial1.write("2");
        // only "send" prints. Nothing in android terminal
        Serial.println("send!");
        delay(1000);
    }

    delay(20);                            
}

What am I doing wrong?
I am using Arduino Leonardo and Bluetooth terminal app on Android device.

user25568: I've found the problem
It should be:
Serial1.println("2");

instead of:
Serial1.write("2");


25568: <p>I am trying to both send and receive data using bluetooth module.</p>

<p>Receiving data works fine with this code:</p>

<pre><code>void setup() { 
    Serial1.begin(9600);
    Serial.begin(9600);
} 

void loop() { 
    if (Serial1.available()) {
        Serial.println(Serial1.read());
    }

    delay(20);                          
}
</code></pre>

<p>But I cannot send any data. This is what I am doing:</p>

<pre><code>void loop() { 
    if (Serial1.available()) {
       Serial.println(Serial1.read());
    }

    delay(20);

    if (digitalRead(bluetoothInput) == HIGH) {
        Serial1.write("2");
        // only "send" prints. Nothing in android terminal
        Serial.println("send!");
        delay(1000);
    }

    delay(20);                            
}
</code></pre>

<p>What am I doing wrong?</p>

<p>I am using Arduino Leonardo and Bluetooth terminal app on Android device.</p>
 25568: <p>I've found the problem</p>

<p>It should be:</p>

<pre><code>Serial1.println("2");
</code></pre>

<p>instead of:</p>

<pre><code>Serial1.write("2");
</code></pre>
