1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
| #include <LiquidCrystal.h>
//Define lcd pins
LiquidCrystal lcd(13,12,8,7,4,2);
//All the things were going to use
int pin = A0;
int pin1 = A1;
int pin2 = A2;
int pin3 = A3;
unsigned long duration;
unsigned long duration1;
unsigned long duration2;
unsigned long duration3;
unsigned int rpm;
unsigned int rpm1;
unsigned int rpm2;
unsigned int rpm3;
void setup()
{
//Set all input pins to input
pinMode(pin, INPUT);
pinMode(pin1, INPUT);
pinMode(pin2, INPUT);
pinMode(pin3, INPUT);
//Let the LCD begin
lcd.begin(16,2);
}
void loop()
{
//Calculate all the RPM's
//X,Y and Z are variables, they depend on what you make of them
//X is the max RPM of your Fan, fill it in
//Y is the reading out of 2 pulses and add it up (see other code)
duration = (pulseIn(pin, HIGH) + pulseIn(pin, HIGH)) / 2;);
rpm = (( XL*Y )/duration);
duration = (pulseIn(pin1, HIGH) + pulseIn(pin1, HIGH)) / 2;
rpm1 = (( XL*Y )/duration1);
duration = (pulseIn(pin2, HIGH) + pulseIn(pin2, HIGH)) / 2;
rpm2 = (( XL*Y )/duration2);
duration = (pulseIn(pin3, HIGH) + pulseIn(pin3, HIGH)) / 2;
rpm3 = (( XL*Y )/duration3);
//Z is the outcome when the rpm is 0, when rpm is 0 it doesn't say 0 but a long number.
//This will change that number in 0
if (rpm = Z){
lcd.setCursor(0,0);
lcd.print("0 ");
}
else {
lcd.setCursor(0,0);
lcd.print(rpm);
}
if (rpm1 = Z){
lcd.setCursor(4,1);
lcd.print("0 ");
}
else {
lcd.setCursor(4,1);
lcd.print(rpm1);
}
if (rpm2 = Z){
lcd.setCursor(8,0);
lcd.print("0 ");
}
else{
lcd.setCursor(8,0);
lcd.print(rpm2);
}
if (rpm3 = Z){
lcd.setCursor(12,1);
lcd.print("0 ");
}
else{
lcd.setCursor(12,1);
lcd.print(rpm3);
}
delay(5000);
lcd.clear();
} |