ED BT Shield

From ElectroDragon Wiki
Revision as of 15:55, 9 September 2013 by Chao (talk | contribs) (→‎Demo Code)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Pin definition

Arduino Pin BT Pin Description
D0 RX Arduino default RX
D1 TX Arduino default TX
D2 LED Status LED
D3 RX1 alternative serial communication pins
D4 TX1 alternative serial communication pins

Demo Code

#include <SoftwareSerial.h>
#define RX1 3
#define TX1 4

SoftwareSerial mySerial(RX1, TX1);
 
void setup()
{
   // define pin modes for tx, rx pins:
   pinMode(RX1, INPUT);
   pinMode(TX1, OUTPUT);
   mySerial.begin(9600);
   Serial.begin(9600);
}
 
void loop()
{
 if (Serial.available()){
 
   mySerial.println((char)Serial.read()); // Print directly what read from Arduino 
 }
 
 if (mySerial.available()) {
     Serial.print((char)mySerial.read()); // print what read from other side of BT
  }
}