two loops and memory

is it possible to have two loops if so what can i call the second loop, this is with a arduino mega2560. i have searched but cant find anything, i just want two loops so in one can jump to the other loop.

next quesiton how do i flag something up in the loop, reason is because i have a loop that sends a email but when it loops again i dont want it sending another email i want it to remember that it has sent one email and not send another one till i cancel the flag or have a ifstatement that cancels the flag..

please help as im stuck thanks

ok so looking at the reply

Perhaps if you describe what you are trying to DO, we can offer some practical help vs. answering abstract questions.

ok so the code is below at the moment i have a arduino mega with arduino ethernet shield, i have made a pressure monitor alarm that monitors the pressure from a pressure tranducer and when it drops below a certain level the alarm is to send a email to my manager.

you will see what i mean about loop below…but in the loop it checks to see weather the pressure is below a certain level if it is, it sends telnet commands to a telnet server to email my manager saying pressure has dropped, but because it is in a loop it will read the value again and send another email. so what i want to do is to send the first email and dont send another till the pressure has got back to tolarance level. i was thinking of the two loop system so that once it has sent an email it goes into another loop to see when the pressure gets back to tolance then that would send a email saying that the pressure is back. once this has happened then it would jump back to the first loop, and both these loops would continue like this. so please how do i do this. hope this makes more sense.

//written by joe winstanley 2/2/11

#include <SPI.h>

#include <Ethernet.h>

byte mac = { 0x90, 0xA2, 0xDA, 0x00, 0x28, 0x67 }; //mac address of arduino
byte ip = { 172, 18, 10, 52 }; //ip address of arduino
byte subnet = {255,255,0,0};
byte gateway = {172, 18, 1, 1};
byte server = { 172, 18, 2, 27}; //email server of penny and giles
int time = 2000;
int wait = 250;

const int analogPin = A5; // pin that the sensor is attached to
const int threshold = 400; // an arbitrary threshold level that’s in the range of the analog input

const int ledPinnot = 4; //green LED for email not being sent
const int ledPinemail = 3; //yellow LED for email being sent

unsigned long lastMail = 0;
unsigned long waitTime = 30000; // 30 seconds should be 1 hour

Client client (server, 25); //sets client as what server and which port to use

void setup()

{pinMode( ledPinnot, OUTPUT); // set pin 4 as output
pinMode( ledPinemail, OUTPUT);// set pin 3 as output

Ethernet.begin(mac, ip, gateway, subnet); //sends all bracketed information to server)
Serial.begin(4800);//prints in COM window

delay(time);}//set delay

void loop()

{int analogValue = analogRead(analogPin);// read the value of the potentiometer

if (analogValue < threshold){Serial.println(“connecting…”);// check to see if the value of the sensor is below the threshold limit

if (client.connect()){Serial.println(“connected”);}//gets arduino to connect to client then print to com3 whats happened
else{ Serial.println(“did not connect connection failed”); }//if arduino dosnt connnect send message to com3

digitalWrite (ledPinemail, HIGH);//light a LED if email is going to be sent
digitalWrite (ledPinnot, LOW);//light a LED if email is going to be sent
client.println(“helo pgxexch01.pag.cw.local” ); //connect to telnet
delay(wait);
client.println(“MAIL From: joe.winstanley@pennyandgiles.com”); //give email address of arduino
delay(wait);
client.println(“RCPT To: joe.winstanley@pennyandgiles.com”); //give email address of manager
delay(wait);
client.println(“DATA”); //body of the email
delay(wait);
client.println(“The Pressur has dropped below its tolerance”); //whats happening in the email
client.println(".");
client.println(“QUIT”); //quit telnet session
delay(wait);

Serial.println(“message sent going to disconnect from client”); //respond back to com3
Serial.println(“disconnected.”);//respond back to com3
client.stop();//cut connection to client to stop time out

delay(60000);
}

else

{ digitalWrite (ledPinnot, HIGH);
digitalWrite (ledPinemail, LOW);}

{ while (client.available()) {
char c = client.read();
Serial.print(c);}

delay (5000);}//end delay before loop starts again

}

i only want one email untill the pressure is back to normal.

the pressure that i messure feeds into test chambers if the pressure in the chamber drops the pressure in the tubes does not change just so you know. i just want to check the pressure in the tubes because that could loose its pressure.

how do i do these flags. thanks for the response really helps thanks