Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- */
- #include <SoftwareSerial.h>
- #include <ShiftRegLCD.h>
- SoftwareSerial xbeeser(1, 0);
- SoftwareSerial btser(7, 8);
- const byte enPin = 5; // SR Clock from Arduino pin 11
- const byte dataPin = 4; // SR Data from Arduino pin 10
- const byte clockPin = 3; // SR Clock from Arduino pin 11
- ShiftRegLCD srlcd(dataPin, clockPin, enPin);
- //want simple XBEE config
- #define XBEESLEEP 6 //Pin 12 for XBee sleep control, goes to pin 9 on xbee
- void setup()
- {
- int result;
- char state=0, temp;
- //xbee
- pinMode (1,INPUT);
- pinMode (0,OUTPUT);
- pinMode(XBEESLEEP,OUTPUT); //6
- //bt
- pinMode (7,INPUT);
- pinMode (8,OUTPUT);
- xbeeser.begin(19200);
- btser.begin(19200);
- srlcd.clear();
- //setup xbee
- digitalWrite(XBEESLEEP, LOW);
- xbeeser.listen();
- srlcd.print("XBee");
- delay(1000);
- xbeeser.print("+++"); // xbeeser.write(0x0D);
- delay(1000);
- while(state != 6)
- {
- if(state == 3)
- {
- state++;
- xbeeser.print("ATCN");
- xbeeser.write(0x0D);
- delay(100);
- }
- if(xbeeser.available())
- {
- temp = xbeeser.read();
- if(temp == 0x0D)
- {
- state++;
- continue;
- }
- if(temp == 'O')
- state++;
- if(temp == 'K')
- state++;
- srlcd.print((char)temp);
- }
- }
- digitalWrite(XBEESLEEP, HIGH);
- //xbee done, now BT
- btser.listen();
- btser.write(0x0D);
- delay(1000);
- btser.print("ATA"); btser.write(0x0D);
- delay(1000);
- while(state != 3)
- {
- if(btser.available())
- {
- temp = btser.read();
- if(temp == 0x0D || temp == 0x0A)
- {
- state++;
- continue;
- }
- if(temp == 'O')
- state++;
- if(temp == 'K')
- state++;
- srlcd.print((char)temp);
- }
- }
- //free of loop :P
- //delay(1000);
- srlcd.clear();
- // Print a message to the LCD.
- srlcd.print("HELLO, WORLD!");
- }
- void loop()
- {
- //put it to sleep
- //digitalWrite(XBEESLEEP, HIGH);
- //Serial.print("test");
- //if read something from serial, output to soft serial, v
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement