Fan RPM Read Help

Hy ,i have this arduino program who can read the RPM speed of a computer fan ,i need the read value to be store in a variable whitch i can use for an AJAX read of a web page,so can some one help me pls modify the program to stere the valua in a "result"variable,thx.

// read RPM

int half_revolutions = 0;
int rpm = 0;
int half_revolutions2 = 0;
int rpm2 = 0;

unsigned long lastmillis = 0;

void setup(){
 
Serial.begin(9600); 
attachInterrupt(0, rpm_fan, FALLING);
attachInterrupt(1, rpm_fan2, FALLING);

}
void loop(){
 
if (millis() - lastmillis == 1000){ //Uptade every one second, this will be equal to reading frecuency (Hz).
 
detachInterrupt(0);//Disable interrupt when calculating
detachInterrupt(1);

rpm = half_revolutions * 30; // Convert frecuency to RPM, note: this works for one interruption per full rotation. For two interrups per full rotation use half_revolutions * 30.
rpm2 = half_revolutions2 * 30;


Serial.print("RPM =\t"); //print the word "RPM" and tab.
Serial.print(rpm); // print the rpm value.

Serial.print("  RPM2 =\t"); //print the word "RPM" and tab.
Serial.println(rpm2); // print the rpm value.

half_revolutions = 0; // Restart the RPM counter
half_revolutions2 = 0;

lastmillis = millis(); // Uptade lasmillis

attachInterrupt(0, rpm_fan, FALLING); //enable interrupt
attachInterrupt(1, rpm_fan2, FALLING);
 }
}
// this code will be executed every time the interrupt 0 (pin2) gets low.

void rpm_fan(){
 half_revolutions++;
}
void rpm_fan2(){
 half_revolutions2++;  
}

It appears that you have 2 fans, one on pin 2 (interrupt 0) and one on pin 3 (interrupt 1) .

The speeds are already in variables: rpm and rpm2.

By the way, put your code between code tags for nice display here.

yes ,you ar right,but my rpm variables ar only calculated in the "void",i need to use them outside the void.

This is quite an advanced topic if you want to use an Arduino based web server to publish web pages which use technology like ajax to display dynamic data. Here is a tutorial which outlines the key technologies: http://startingelectronics.org/tutorials/arduino/ethernet-shield-web-server-tutorial/

theat is what i`m using,but i need the rpm variable,ouside the void loop,

rpm (and rpm2) are already global variables. You can access these outside the main (void) loop. Is that what you want ?