how to do parallel processing?

I m new to arduino world... i want to give an interrupt when no. of led blinks exceeds given count in one minute and turn the alarm on while my main code is busy in doing other important processing... how do i use interrupts and timers... i m need of code urgently....
first of all how do i count no. of led blinks in 1 MINUTE???

i want to give an interrupt

What are you giving the interrupt to?

To count the number of blinks in one minute, do the following:

const int BLINKS_BEFORE_ALARM = 100;

unsigned long blinkTime[BLINKS_BEFORE_ALARM];
int blinkCount;

unsigned long time;

int x, y;


time = milliseconds(); // Do this at the start of your main loop.

// Then, remove blinks from queue which are too old:

for (x = 0; x<BLINKS_BEFORE_ALARM; x++) { // Scan through array for blinks which occured over one second ago.
  if ((time-blinkTime[x]) < 1000) { // If this recorded time is within 1 second of the current time, stop stepping through the array, shift the remainder of it down, and adjust the blink count.
    for (y = x; y<BLINKS_BEFORE_ALARM; y++) {  // Shift array down by the number of blinks which were over one second ago.
      blinkTime[x] = blinkTime[y];      
    }  
    blinkCount = blinkCount - x; // Adjust the count of the number of blinks stored in the array downward by the number of blinks which were over one second ago.
    break; // Exit loop x early.
  }    
}

// After doing that, blinkCount tells you how many blinks occured in the last second.
If (blinkCount >= BLINKS_BEFORE_ALARM) { alarm(); }

// And whenever a new blink occurs, you do this:
if (blink) { 
  blinkTime[blinkCount] = time;
  blinkCount++
}

// But you can't do that inside a timer interrupt, because your main loop may be executing at the same time, and if you modify the arrayor blinkCount while you are in the middle of a loop which is using them, bad things will happen.

// We'll need to know more about how the interrupt code will work to avoid that issue.

i need to giv interrupt to arduino..
I'l giv brief about my project for accident prevention..
I m using 3 sensors i.e alcohol sensor for detecting alcohol intake, eye blink sensor for fatigue dtection and GL ultrasonic sensor for collision avoidance.These sensors are interfaced to arduno along with lcd for display, motor control and alarm..
My code for alcohol detyection is ready in main loop.. It senses alcohol continuously and slows down motor if it exceeds threshold with results displayed on lcd..
i want some way so that no. of eye(led) blinks (given by falling edges) to be counted in 1 min and if no.of blinks exceeds threshold i.e 8 in 1 min, interrupt(0) to be given to arduino and isr should turn onthe alarm..
Other thing is it should take inputs from ultasonic sensor also continuously and if threshold exceeds it should giv interrupt(1) again annd in isr should slow down or stop the motor...
Need help.. how to do all 3 processes simultaneously??

i need to giv interrupt to arduino

I think you've misunderstood what an interrupt is.

If the Arduino is doing the detection, then it shouldn't need to interrupt itself.

then how do i go about it?? as in how i'l make these thigs to work parallely??

Cant i use counter/timer interrupt and do something???

"parallel" is the wrong word - "concurrent" is more like it.
Have a look at the blink without delay tutorial to see how you can do this.

An interrupt is normally a signal to the processor from the outside that something has happened.
Here, the processor is the source of the "something has happened", so an interrupt is a bit of a waste of time and effort.

thanks...
but i want to count the no. of blinks in 1 min and not to blink the led... how do i do it concurrently with other part of the code?? I want all 3 sensors to sense continuously and take necessary actions..

but i want to count the no. of blinks in 1 min and not to blink the led

So, you use the timer arithmetic to measure time periods, and count up blinks from whatever input provides them, and work it out from there.

how to use timer arithmetic to measure time periods?? Can u please explain me with the code??

how to use timer arithmetic to measure time periods?? Can u please explain me with the code??

This is why it is useful to read and understand the blink without delay tutorial.

the problem is dat ma other code is running simultaneously...so how do i use millis() as other delays will be included in it??

No, you use "millis" so that you don't have to use "delay"

Delays that i have used in my rest code will alter the timing and will not give me exact 1 min using
millis().. how to count blinks in 1 min irrespective of other part of the code??

You...don't...use..delays.

Got that?

Depending upon the results of alcohol sensor i need to slow down the motor and then stop it for 15 min.. so i have to use delays.. even while displaying on lcd i hav to use delays...no other option...

so i have to use delays

I don't quite know how to break this to you.
No, you don't.

Read the Blink without delay example provided in the IDE, then understand it!!

As shown in the blink without delay example you need to look at how much time as passed before doing something instead of creating a delay.

So in your loop you would have an IF statement for each "delay" you need that would check to see how much time has passed since it last started or ended. The easiest way to think of how this works is to assume that everything in the loop happens instantly over and over again but the time that has past keeps going up. So keep checking the time that has passed then do what needs to be done once the time has passed and reset your counter for that particular function.

If you want to run 3 "parallel" processes at the same time that each have a different "delay" you would need a variable for each that had the start time. You then compare this time to the current time and decide if enough time has past to change the outcome... if not, then continue, if so, then change a variable or do something, reset your start time variable and continue.