How to run two programas at the same time?

I have two codes:

int rel=9; char dato;

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

void loop() {;

if (dato=='a'){ digitalWrite(rel,HIGH); Serial.println("J Apagado" ); delay(60000); } else digitalWrite(rel,LOW); Serial.println("J Encendido"); delay (2000); }

And this, that I need run all the time

float temp=0; int fan=8;

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

void loop(){ temp=(5.0 * analogRead(0)*100.0)/1023.0; Serial.println(temp); delay(2000);

if(temp>27){ digitalWrite(8,HIGH); delay(60000); } else digitalWrite(8,LOW);


Any ideas?. Thanks.

An Arduino can only have one program so you need to merge the two programs into one. This merge demo may help.

If you need the program to operate so that it appears to do 2 things at the same time see the demo several things at a time which shows how to manage timing with millis() rather than delay().