document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. cli();
  2. sei();
  3.  
  4.  
  5. int NbTopsFan;
  6. int Calc;
  7.  
  8. //Sensore della ventola, cavo giallo
  9. int hallsensor = 2;
  10.  
  11.  
  12. typedef struct{
  13. char fantype;
  14. unsigned int fandiv;
  15. }fanspec;
  16.  
  17. //Definitions of the fans
  18. fanspec fanspace[3]={{0,1},{1,2},{2,8}};
  19.  
  20. char fan = 1;
  21.  
  22.  
  23. void rpm ()
  24. {
  25. NbTopsFan++;
  26. }
  27. void setup()
  28. {
  29. pinMode(hallsensor, INPUT);
  30. Serial.begin(9600);
  31. attachInterrupt(0, rpm, RISING);
  32. }
  33. void loop ()
  34. {
  35. NbTopsFan = 0;
  36. sei();
  37. delay (1000);
  38. cli();
  39. Calc = ((NbTopsFan * 60)/fanspace[fan].fandiv);
  40. Serial.print (Calc, DEC);
  41. Serial.print (" rpm\\r\\n");
');