PC Master / Bluetooth Module Slave

I'm trying to send input to light 1 of 3 leds using my arduino pro with bluetooth module. Ideally, I want to use the arduino Serial Monitor to send commands like 1,2,3 for the menu choices, then have my arduino board with bluetooth module response to those commands. Please help me. XD

I make the assumption that bluetooth.read() is reading the RX pin 0 and bluetooth.write() is writing to the TX pin 1. The only examples I've seen are using the bluetooth module to send data to other bluetooth devices like an Android phone. What's different is I want my bluetooth module to receive data for input to other operations, such as, controlling the direct of a motor.

Example I've seen for sending with the bluetooth module: (interesting, but that is next program I'll work on)

/*
Evan Johnson
Description: test sending serial input to turn on 1 of 3 leds.
 
 */
#include <SoftwareSerial.h>

int bluetoothTx = 1;
int bluetoothRx = 0;

int led1 = 2;
int led2 = 3;
int led3 = 4;

SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);

void setup()
{
  // This code will only run once, after each powerup or reset of the board
  pinMode(led1, OUTPUT);
  pinMode(led2, OUTPUT);
  pinMode(led3, OUTPUT);

  // This code will loops consecutively
  Serial.begin(115200);
  bluetooth.begin(115200);
  delay(100);
  
  Serial.print("Evan's 3 Leds\n");
  Serial.print("1 for led1\n");
  Serial.print("2 for led2\n");
  Serial.print("3 for led3\n");
  Serial.print("Your choice: ");
  
  delay(100);

  
  for(int i=0; i<3; i++)
  {
    digitalWrite(led1, HIGH);
    delay(500);
    digitalWrite(led1, LOW);
    delay(500);
    digitalWrite(led2, HIGH);
    delay(500);
    digitalWrite(led2, LOW);
    delay(500);
    digitalWrite(led3, HIGH);
    delay(500);
    digitalWrite(led3, LOW);
    delay(500);
  }
  
  
}

void loop()
{

  if(Serial.available())
  {
    int inputRX = bluetooth.write(Serial.read());
      
    switch(inputRX)
        {
          case '1':
          {
            Serial.println("Light led1 for 2 seconds.");
            digitalWrite(led1, HIGH);
            delay(2000);
            digitalWrite(led1, LOW);
            break;
          }
          case '2':
          {
            Serial.println("Light led2 for 2 seconds.");
            digitalWrite(led2, HIGH);
            delay(2000);
            digitalWrite(led2, LOW);
            break;
          }
          case '3':
          {
            Serial.println("Light led3 for 2 seconds.");
            digitalWrite(led3, HIGH);
            delay(2000);
            digitalWrite(led3, LOW);
            break;
          }
          default:
          {
            break;
          }
        }
     }
     delay(1);
  }

You can't do software serial on the hardware serial pins.

Which library can I use on the hardware serial pins?

Which library can I use on the hardware serial pins?

HardwareSerial - instanced for you as Serial.

For the task of lighting leds via Serial, which library do I need? Maybe I need SoftwareSerial bluetooth(2,3); or Serial bluetooth(1,0); I'd appreciate a little more guidance if you can see where I'm trying to go with this idea.

From the point of view of the HardwareSerial class/Serial instance, it does not matter what is connected to the pins. Just use Serial.read() to read from the bluetooth device, when it is connected to pins 0 and 1, and use Serial.print(ln)() or Serial.write() to write to it.

If you move the device to other pins, then you can use SoftwareSerial to access the device on those pins.

ah yes thank you! I got my sketch working using TX1/RX0 pins. HOWEVER, on the Arduino Pro 5V I originally want to use TX/RX male header pins on the FTDI connector, but that wasn't working, so I tapped into TX1/RX0 pins. How can I get my sketch working using TX/RX on FTDI connector? :expressionless: