user34737: So I'm trying to learn basic Android app dev. My master plan was to make an app using MIT App Inventor that would turn on an LED over Bluetooth using an Arduino. Once I verified that everything worked, I would write the entire app from scratch using Android Studio. This way, when I inevitably run into bugs with my written-from-scratch app, I could say with 100% certainty that the issue is in my Android code and not hardware/Arduino related.
So I'm having trouble right now. I have two separate LED circuits, a blue LED from port 13 and a green LED from pin 8. I verified that both circuits are working properly by using the Blink code, so I know the issue is definitely not with the LED circuits.
I'm using an HC 06 Bluetooth module. The pins are connected as follows:
HC 06 -> Arduino
RX -> TX
TX -> RX
5V -> 5V
GND -> GND
Here is the Arduino code:

#include <SoftwareSerial.h>

SoftwareSerial bluetooth(0,1);
int ledblue = 13;
int ledgreen = 8;
int tx = 1;
int rx = 0;
int type;

void setup() {
  Serial.begin(9600);
  //bluetooth.begin(9600);
  pinMode(ledblue, OUTPUT);
  pinMode(ledgreen, OUTPUT);
  pinMode(tx, OUTPUT);
  pinMode(rx, INPUT);
  allpinslow();
}

void loop() {
  int i = 0;
  int m = 0;
  delay(500);
  if (Serial.available() > 0) {
    while(Serial.available() > 0){
      type = Serial.read();
      Serial.println(type);
    }
    Check_Protocol(type);
  }
}

void allpinslow()
{
  digitalWrite(ledgreen, LOW);
  digitalWrite(ledblue, LOW);
}

void Check_Protocol(int inStr) {
  int i = 0;
  int m = 0;
  if (inStr == '0') { //Led Off equals("2off")
    allpinslow();
  }
  if (inStr == '1') { //Led on
    digitalWrite(ledblue, HIGH);
  }
  if (inStr == '2'){
    digitalWrite(ledgreen,HIGH);
  }
}

Here is the MIT App Inventor block code

If I press the Green or Off button, the Serial Monitor spits out 255. If I press Red, nothing shows up on the serial monitor. I'm a bit dumbfounded on what is broken so I would greatly appreciate any help I can get.
Edit: @Delta_G here is the modified code
#include <SoftwareSerial.h>
int ledblue = 13;
int ledgreen = 8;
SoftwareSerial mySerial(2,4); //RX, TX
int type;

void setup() {
  Serial.begin(9600);
  mySerial.begin(9600);
  pinMode(ledblue, OUTPUT);
  pinMode(ledgreen, OUTPUT);
  allpinslow();
}

void loop() {
  int i = 0;
  int m = 0;
  delay(500);
  if (mySerial.available()) {
    while(mySerial.available()){
      type = mySerial.read();
      Serial.println(type);
    }
    Check_Protocol(type);
    //Serial.println(inSerial);
  }
}

void allpinslow()
{
  digitalWrite(ledblue, HIGH);
  digitalWrite(ledblue, LOW);
}

void Check_Protocol(int inStr) {
  int i = 0;
  int m = 0;
  if (inStr == '0') { //Led Off equals("2off")
    digitalWrite(ledblue, LOW);
    digitalWrite(ledgreen, LOW);
  }
  if (inStr == '1') { //Led on
    digitalWrite(ledblue, HIGH);
  }
  if (inStr == '2'){
    digitalWrite(ledgreen,HIGH);
  }
}


user34737: Update: It was a faulty Bluetooth module that was causing the issues. I bought a new one and everything works perfectly!

34737: <p>So I'm trying to learn basic Android app dev. My master plan was to make an app using MIT App Inventor that would turn on an LED over Bluetooth using an Arduino. Once I verified that everything worked, I would write the entire app from scratch using Android Studio. This way, when I inevitably run into bugs with my written-from-scratch app, I could say with 100% certainty that the issue is in my Android code and not hardware/Arduino related.</p>

<p>So I'm having trouble right now. I have two separate LED circuits, a blue LED from port 13 and a green LED from pin 8. I verified that both circuits are working properly by using the Blink code, so I know the issue is definitely not with the LED circuits.</p>

<p>I'm using an HC 06 Bluetooth module. The pins are connected as follows:</p>

<p>HC 06 -> Arduino</p>

<p>RX -> TX</p>

<p>TX -> RX</p>

<p>5V -> 5V</p>

<p>GND -> GND</p>

<p>Here is the Arduino code:
</p>

<pre class="lang-cpp prettyprint-override"><code>#include &lt;SoftwareSerial.h&gt;

SoftwareSerial bluetooth(0,1);
int ledblue = 13;
int ledgreen = 8;
int tx = 1;
int rx = 0;
int type;

void setup() {
  Serial.begin(9600);
  //bluetooth.begin(9600);
  pinMode(ledblue, OUTPUT);
  pinMode(ledgreen, OUTPUT);
  pinMode(tx, OUTPUT);
  pinMode(rx, INPUT);
  allpinslow();
}

void loop() {
  int i = 0;
  int m = 0;
  delay(500);
  if (Serial.available() &gt; 0) {
    while(Serial.available() &gt; 0){
      type = Serial.read();
      Serial.println(type);
    }
    Check_Protocol(type);
  }
}

void allpinslow()
{
  digitalWrite(ledgreen, LOW);
  digitalWrite(ledblue, LOW);
}

void Check_Protocol(int inStr) {
  int i = 0;
  int m = 0;
  if (inStr == '0') { //Led Off equals("2off")
    allpinslow();
  }
  if (inStr == '1') { //Led on
    digitalWrite(ledblue, HIGH);
  }
  if (inStr == '2'){
    digitalWrite(ledgreen,HIGH);
  }
}
</code></pre>

<p>Here is the MIT App Inventor block code</p>

<p><a href="https://i.stack.imgur.com/C0Gcq.png" rel="nofollow noreferrer" title="MIT App Inventor block code"><img src="https://i.stack.imgur.com/C0Gcq.png" alt="MIT App Inventor block code" title="MIT App Inventor block code"></a></p>

<p>If I press the Green or Off button, the Serial Monitor spits out 255. If I press Red, nothing shows up on the serial monitor. I'm a bit dumbfounded on what is broken so I would greatly appreciate any help I can get.</p>

<p>Edit: @Delta_G here is the modified code</p>

<pre class="lang-cpp prettyprint-override"><code>#include &lt;SoftwareSerial.h&gt;
int ledblue = 13;
int ledgreen = 8;
SoftwareSerial mySerial(2,4); //RX, TX
int type;

void setup() {
  Serial.begin(9600);
  mySerial.begin(9600);
  pinMode(ledblue, OUTPUT);
  pinMode(ledgreen, OUTPUT);
  allpinslow();
}

void loop() {
  int i = 0;
  int m = 0;
  delay(500);
  if (mySerial.available()) {
    while(mySerial.available()){
      type = mySerial.read();
      Serial.println(type);
    }
    Check_Protocol(type);
    //Serial.println(inSerial);
  }
}

void allpinslow()
{
  digitalWrite(ledblue, HIGH);
  digitalWrite(ledblue, LOW);
}

void Check_Protocol(int inStr) {
  int i = 0;
  int m = 0;
  if (inStr == '0') { //Led Off equals("2off")
    digitalWrite(ledblue, LOW);
    digitalWrite(ledgreen, LOW);
  }
  if (inStr == '1') { //Led on
    digitalWrite(ledblue, HIGH);
  }
  if (inStr == '2'){
    digitalWrite(ledgreen,HIGH);
  }
}
</code></pre>
 34737: <p>Update: It was a faulty Bluetooth module that was causing the issues. I bought a new one and everything works perfectly!</p>
