Computers, Development Boards & Shields
Educational & Robotics Kits
Electronic Sensors
Motors & Controllers
Communication & Display
Electronic Components
Soldering & Lab Tools

0
Using SoftwareSerial with Virtuabotix BT2S Slave or Master

When i bridge the Tx and Rx on the Virtuabotix BT2S I receive what I send through blueterm, so that’s working ok… i have been running the Arduino off battery to ensure the USB serial doesn’t interfere… can i use SoftwareSerial with this to use different pins than Tx and Rx? here’s the code i’m trying to use:

#include <SoftwareSerial.h>
int counter = 0;
int incomingByte;
void setup()
{
  Serial.begin(9600);
  SoftwareSerial mySerial(6, 7); // RX, TX
  pinMode(13,OUTPUT);
}
void loop()
{
  // see if there’s incoming serial data:
  if (Serial.available() > 0)
  {
    // read the oldest byte in the serial buffer:
    incomingByte = Serial.read();
    // if it’s a capital R, reset the counter
    if (incomingByte == ‘R’)
{
      Serial.println(“RESET”);
      counter=0;
    }
  }
  //only count to 100 then stop aka don’t count to infinity
  if(counter<100)
  {
Serial.println(counter); //displays the ACSII number/letter
counter++;
delay(250);
  }
}

3 Answers

0

Derrick,

All you need to do to get the software serial working is replace Serial with mySerial. Adding a software serial port does not negate the existing built in commands.
//#####################CODE#############################
#include <SoftwareSerial.h>

int counter = 0;
int incomingByte;
void setup()
{
  Serial.begin(9600);
  SoftwareSerial mySerial(6, 7); // RX, TX
  pinMode(13,OUTPUT);
}
void loop()
{
  // see if there’s incoming serial data:
  if (mySerial.available() > 0)
  {
    // read the oldest byte in the serial buffer:
    incomingByte = mySerial.read();
    // if it’s a capital R, reset the counter
    if (incomingByte == ‘R’)
{
      mySerial.println(“RESET”);
      counter=0;
    }
  }
  //only count to 100 then stop aka don’t count to infinity
  if(counter<100)
  {
mySerial.println(counter); //displays the ACSII number/letter
counter++;
delay(250);
  }
}
//#####################END CODE#########################
Let me know if that resolves your problem.
0

Main thankyou Brian on another wonderful resource that will aid the entire marketplace.
oakley pas cher

0
0

I actually undoubtedly would rather a new Mac book Surroundings to get $999 in comparison with a good ipad tablet 64GB with regard to $699
mont blanc pens http://www.kmea.org/montblanc/

0

Your Answer

No comments yet.

Leave a Reply