Using Bluetooth Instead of XBee (help with the code?)

Some background:

I found some code that uses the xbees to simulate the i/o link on Texas Instruments ti 83 and 84's, but I want to use a bluetooth module of some sort instead. I haven't done anything with arduino for the last 5ish years so I don't remember much. Any ideas / comments, anyone?

Here is the code I found:

define RED_WIRE 6

define WHITE_WIRE 7

void setup() {

// start the serial for the xbee Serial.begin(9600);

// debug light pinMode(13,OUTPUT);

}

void loop() { // send data only when you receive data: if (Serial.available() > 0) { // read the incoming byte: unsigned char incomingByte = Serial.read(); sendByte(incomingByte); }

// if a wire is pulled low then start reading by calling the get method if(!(digitalRead(RED_WIRE)==1 && digitalRead(WHITE_WIRE)==1)) {

// turn on debug light digitalWrite(13, HIGH); Serial.write(get()); // turn off debug light digitalWrite(13, LOW); }

}

void sendByte(unsigned char toSend) { for (int b1 =0;b1<8;b1++){ if(toSend & 1){ pinMode(WHITE_WIRE,OUTPUT); digitalWrite(WHITE_WIRE,LOW); while(digitalRead(RED_WIRE)==1) {} pinMode(WHITE_WIRE,INPUT); while(digitalRead(RED_WIRE)==0) {} }else{ pinMode(RED_WIRE,OUTPUT); digitalWrite(RED_WIRE,LOW); while(digitalRead(WHITE_WIRE)==1) {} pinMode(RED_WIRE,INPUT); while(digitalRead(WHITE_WIRE)==0) {} } toSend = toSend>>1; } }

unsigned char get() { unsigned char data=0; for(int b1=0; b1<8; b1++){ while(digitalRead(RED_WIRE)==1 & digitalRead(WHITE_WIRE)==1) {} if (digitalRead(RED_WIRE) == 1){ data = (data >> 1) | 0x80; pinMode(RED_WIRE,OUTPUT); digitalWrite(RED_WIRE,LOW); while(digitalRead(WHITE_WIRE)==0) {} digitalWrite(RED_WIRE,HIGH); pinMode(RED_WIRE,INPUT); } else { data = data >> 1; pinMode(WHITE_WIRE,OUTPUT); digitalWrite(WHITE_WIRE,LOW); while(digitalRead(RED_WIRE)==0) {} digitalWrite(WHITE_WIRE,HIGH); pinMode(WHITE_WIRE,INPUT); } } return data; }

Any ideas / comments, anyone?

There are no code changes needed, as long as the bluetooth module is connected to the same pins that the XBee was connected to.

However, I find it difficult to believe that that code was sending data via XBees.

Okay, I have no idea if it works right at all. I'll find out, I guess.

PaulS: There are no code changes needed, as long as the bluetooth module is connected to the same pins that the XBee was connected to.

However, I find it difficult to believe that that code was sending data via XBees.

How it it hard to believe it was using xbees?

thanks

How it it hard to believe it was using xbees?

Because XBees send and receive serial data. That code is bit-banging sending serial data, which I'm not sure the XBee will understand. I could be wrong, and it could work perfectly fine. I just don't understand why the code is not just using Serial.print() or Serial.write().