Medidor RPM Con Arduino
Medidor RPM Con Arduino
Parts List;
1) 1x 162 parallel LCD display (compatible with Hitachi HD44780 driver)
2) 1x Arduino
3) 1x 10k potentiometer
4) 1x 10k resistor
5) 1x IR LED
6) 1x IR Phototransistor
7) Jumper wire
Instruction;
1) Connect all jumper wire as shown in diagram.
//Turn on IR LED
pinMode(ledPin, OUTPUT);
digitalWrite(ledPin, HIGH);
rpmcount = 0;
rpm = 0;
timeold = 0;
}
void loop()
{
//Update RPM every second
delay(1000);
//Don't process interrupts during calculations
detachInterrupt(0);
//Note that this would be 60*1000/(millis() - timeold)*rpmcount if the interrupt
//happened once per revolution instead of twice. Other multiples could be
used
//for multi-bladed propellers or fans
rpm = 30*1000/(millis() - timeold)*rpmcount;
timeold = millis();
rpmcount = 0;
//Print out result to lcd
lcd.clear();
lcd.print("RPM=");
lcd.print(rpm);
//Restart the interrupt processing
attachInterrupt(0, rpm_fun, FALLING);
}
Note:
This code reading rpm with 2 propeller at the motor. This mean 2 cut of the
infrared beam will count as 1 revolution. You can modify this line to suit your
use;
rpm = 30*1000/(millis() timeold)*rpmcount;