I would like to know where I can go and look to see how. To take the (Tx Code) program and add the (TxRx11 code). Take the (Rx code) and add it to the (TxRx code99).
I am looking to send the serial data with the xbee's using tx and rx.
((RxTx11))
//TxRx11 Code..........
#include <SoftwareSerial.h>
#define Rx 6 // DOUT to pin 6
#define Tx 7 // DIN to pin 7
SoftwareSerial Xbee (Rx, Tx);
void setup() {
Serial.begin(9600); // Set to No line ending;
Xbee.begin(9600); // type a char, then hit enter
delay(500);
}
void loop() {
if(Serial.available()) { // Is serial data available?
char outgoing = Serial.read(); // Read character, send to XBee
Xbee.print(outgoing);
}
if(Xbee.available()) { // Is data available from XBee?
char incoming = Xbee.read(); // Read character,
Serial.println(incoming); // send to Serial Monitor
}
delay(50);
}
((RxTx99))
//TxRx99 Code..........
#include <SoftwareSerial.h>
#define Rx 6 // DOUT to pin 6
#define Tx 7 // DIN to pin 7
SoftwareSerial Xbee (Rx, Tx);
void setup() {
Serial.begin(9600); // Set to No line ending;
Xbee.begin(9600); // type a char, then hit enter
delay(500);
}
void loop() {
if(Serial.available()) { // Is serial data available?
char outgoing = Serial.read(); // Read character, send to XBee
Xbee.print(outgoing);
}
if(Xbee.available()) { // Is data available from XBee?
char incoming = Xbee.read(); // Read character,
Serial.println(incoming); // send to Serial Monitor
}
delay(50);
}
((Tx))
//Tx Code..........
int buttonPin = 10;
void setup ()
{
Serial.begin(9600);
pinMode (buttonPin, INPUT);
}
int currState;
int prevState = HIGH;
void loop()
{
currState = digitalRead(buttonPin);
if(currState != prevState)
{
// A transition occurred...
if(currState == HIGH)
Serial.print('1');
else
Serial.print('0');
}
prevState = currState;
}
((Rx))
//Rx Code........
int LedPin = 13;
void setup ()
{
Serial.begin(9600);
pinMode (LedPin, OUTPUT);
}
void loop()
{
int Rx = Serial.read() - '0';
if (Rx == 1)
{
Serial.println("Led is on");
digitalWrite(LedPin,HIGH);
}
else if (Rx == 0)
{
Serial.println("Led is off");
digitalWrite(LedPin,LOW);
}
else
{
Serial.println("Invalid!");
}
}