Running two processes

I am trying to simultaneously read temperature remotely from a temperature sensor through the router Xbee to the coordinator Xbee and do the same but remotely control LEDs from digital inputs on the keyboard.
With my code below I can only read one input at a time so I’m not exactly sure what to do as i have tried interrupts and delays.
Any help please.

int myData = 0;
int ledCool = 2;
int ledWarn = 4; 
int const ledControl = 7;
float temp;
void setup() {
 pinMode(ledCool, OUTPUT);  
 pinMode(ledWarn, OUTPUT);
 pinMode(ledControl, OUTPUT);  

void loop(){

void remoteTemp(){
 // Remote XBee: AT, Base XBee: API
if (Serial.available() >= 21) { // Make sure the frame is all there
 if ( == 0x7E) { // 7E is the start byte
   for (int i = 1; i<19; i++) { // Skip ahead to the analog data
     byte discardByte =;
//Reading the temperature
int analogMSB =; // Read the first analog byte data
int analogLSB =; // Read the second byte
int analogReading = analogLSB + (analogMSB * 256);
temp = analogReading / 1023.0 * 1.23;
temp = temp - 0.5;
temp = temp / 0.01;
if (temp < 21){
 Serial.println(" degrees C");}
else if (temp >= 21){
   Serial.print("WARNING Temperature is ");
   Serial.println(" degrees C");

void remoteLight(){
//On/Off switch from keypad
if(Serial.available() > 0){
  myData =;//Read the data from the keypad
  if(myData == '1'){
   digitalWrite(ledControl, HIGH);
   Serial.println(" On");}
 if(myData == '2'){
   digitalWrite(ledControl, LOW);

Please use code tags when posting code. You can go back and edit your post to include them.

The Arduino processors have a lot of CPU power, more than enough for the task you are programming.

You will never get responsive software if you use delay() in your code. The software does NOTHING while the delay is running.


These delays are completely unnecessary.

When it comes to blinking LEDs, you need to understand the BlinkWithoutDelay example, using millis() to time when the state of a LED needs to change, and then implement a similar technique in your code.

Thanks I will have a look at that now

It looks like you are trying to use the one Serial instance to get data from the PC and from the XBee. That is never going to work.