Hi
Thanks for all your replies...........I read in the Arduino reference that "goto" wasnt looked upon too kindly, but I didnt realize it was such a huge taboo!!
After a bit of playing around I managed to get the code working properly
const int data = 12;
const int xfcbutton = 2;
int buttonState = 1;
// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(data, OUTPUT);
pinMode(xfcbutton, INPUT);
digitalWrite(data, HIGH); // sets data out to high initially
}
// Preamble = 0000000 followed by marker
// XFC data first time through = 0100 0 1000 0 0011 0 0010 0
// XFC data second time through = 0000 0 1000 0 0011 0 0010 0
void loop() {
while (digitalRead(xfcbutton) == HIGH){}
digitalWrite(data, LOW); // Zero starts Preamble starts 0000000 + marker
delayMicroseconds(190); //
digitalWrite(data, HIGH); //
delayMicroseconds(230); // Zero ends
// some code removed
digitalWrite(data, LOW); // marker starts
delayMicroseconds(190);
digitalWrite(data, HIGH); //
delayMicroseconds(795); // marker ends End of preamble
// first 20 bit data stream begins
//delay(5);
digitalWrite(data, LOW); // Zero starts 0100
delayMicroseconds(190);
digitalWrite(data, HIGH);
delayMicroseconds(230); // Zero ends
//some code removed
digitalWrite(data, LOW); // Zero starts 0
delayMicroseconds(190);
digitalWrite(data, HIGH);
delayMicroseconds(230); // Zero ends
// First 20 bit data stream ends
// Second 20 bit data stream begins
do {
//delay(5);
digitalWrite(data, LOW); // Zero starts 0000
delayMicroseconds(190);
digitalWrite(data, HIGH);
delayMicroseconds(230); // Zero ends
//some code removed so that I can post this!!
digitalWrite(data, LOW); // Zero starts 0
delayMicroseconds(190);
digitalWrite(data, HIGH);
delayMicroseconds(230); // Zero ends
// second pass through finishes
// delay (10);
}
while (digitalRead(xfcbutton) == LOW);
}