Help with my Project please

I have writen the following code to pulse an LED every two seconds

I am also using an XBee module and want to keep the LED on when I press a '1' on my PC to represent an input

But when I ran the programme the LED works untill I placed the XBee sheild on the Uno board and the LED will not work any ideas?

test_fri_30.ino (572 Bytes)

Here is his code:

int led = 13;
byte pinState = 0;
int myData = 0; 

void setup() 
{                
  pinMode(led, OUTPUT);     
  Serial.begin(9600);
}

void loop() 
{
  {
    digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(1000);               // for a second
    digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
    delay(2000);               // for two seconds
  }


  if(Serial.available() > 0){
    myData = Serial.read();
    if(myData == '1')
      digitalWrite(led, HIGH); //if '1' is pressed on computer LED on Arduino Uno board will light
  }
}

I don't see how that would work with our without the shield, because in the first part of loop you are turning the LED on and off anyway (whether or not you have serial input).

Ok, so how would I fix the programme.

The purpose of the circuit is an alarm type, I want an LED to blink every two seconds to prove the system is working

Upon an input from my computer the LED should be constant until the board is reset

  {
    digitalWrite(led, HIGH);   // turn the LED on (HIGH is the voltage level)
    delay(1000);               // for a second
    digitalWrite(led, LOW);    // turn the LED off by making the voltage LOW
    delay(2000);               // for two seconds
  }

What are these curly braces here for?

You have to decide under what conditions the LED should flash and under what conditions it should be on solid.

Personally, I'd use two different LEDs - one flashing to indicate that the system is working and one to indicate that it received a 1 from the serial port.

You might also want to consider some way to turn the LED off again.

The coding issues have nothing to do with the XBee or shield being in place or not.