Arduino RPM Counter / Tachometer

by Rezz on October 9, 2011

Arduino projects, make arduino rpm counter with arduino.

Parts List;
1) 1x 16×2 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.

2) Connect IR LED to digital pin 13.

3) Connect IR Phototransistor (dark) to digital pin 2. Make sure shorter lead connected to digital pin 2 and longer lead to Ground.

Upload this code to your arduino

/*
 * Optical Tachometer
 *
 * Uses an IR LED and IR phototransistor to implement an optical tachometer.
 * The IR LED is connected to pin 13 and ran continually.
 * Pin 2 (interrupt 0) is connected across the IR detector.
 *
 * Code based on: www.instructables.com/id/Arduino-Based-Optical-Tachometer/
 * Coded by: arduinoprojects101.com
 */

int ledPin = 13;                // IR LED connected to digital pin 13
volatile byte rpmcount;
unsigned int rpm;
unsigned long timeold;

// include the library code:
#include <LiquidCrystal.h>
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

void rpm_fun()
 {
   //Each rotation, this interrupt function is run twice, so take that into consideration for 
   //calculating RPM
   //Update count
      rpmcount++;
 }

void setup()
 {
   lcd.begin(16, 2);  // intialise the LCD

   //Interrupt 0 is digital pin 2, so that is where the IR detector is connected
   //Triggers on FALLING (change from HIGH to LOW)
   attachInterrupt(0, rpm_fun, FALLING);

   //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;

 

{ 33 comments… read them below or add one }

Verónica February 17, 2015 at 3:29 am

I´m sorry i don´t speak english very well, but i´m try to explain my question…
in the display i can´t see RPM=0..
i did everything you said on the page,, but the program, not working..
could you help me please??

Reply

Sisir Kumar March 24, 2015 at 6:04 am

Can I stop the power supply to a DC motor if it reaches a certain rpm.
If so pls tell me how to do it.
Also tell how to code it.
Thanks in advance…..

Reply

sanket March 28, 2015 at 8:07 am

how can we modify the code for one propeller motor

Reply

Luca April 17, 2015 at 8:42 pm

hi,
can you give me the specific components name for ir phototransistor and led?

Reply

erazo avila angel April 26, 2015 at 5:18 pm

como hago si tengo 15 helices en mi motro cual es la formula o como la calculo porfavor enseñame

Reply

HermannSW May 3, 2015 at 9:52 am

Hi,

nice project, I found it after doing my own tachometer, with fork type light barrier TCST 2103:
https://twitter.com/HermannSW/status/594288163268485120

My code is similar to yours (here is a related discussion of measurement precision: http://forum.arduino.cc/index.php?topic=155589.0).

Use of fork type light barrier finally allowed me to get all parts fixped by a big paper clip allowing to run without manual interaction:
https://twitter.com/HermannSW/status/594784972424216576

The 14700rpm measured were below 23200rpm I expected; measurment of effective motor voltage (3.0V) after motor driver revealed the issue (nominal voltage is 4.5V).

Your project description allows me just to point to it instead of “fritzing” a diagram and description myself, thanks.

Hermann.

Reply

sally May 3, 2015 at 8:36 pm

I can’t find where do I connect the motor, and what kind of motor should I use?

Reply

Sovatna May 17, 2015 at 3:29 pm

Thank you. Ery for your wonderful projects. By the way, can we apply this to measure engine speed?

Reply

Ayşe May 20, 2015 at 1:31 pm

Hi,
How many rpm you can count with tachometer?

Reply

Ayşe May 20, 2015 at 9:17 pm

Hi,
How much the last rpm can we measure with this tachometer?

Reply

jesus May 29, 2015 at 3:14 pm

me sale un error en un renglon al momento de cargarlo a arduino me podrias ayudar
volátil byte rpmcount;
en esa parte me sale el error

Reply

Juan Carlos June 11, 2015 at 5:51 pm

Hello,

You must change 13th line
volatile byte rpmcount; // non stable rmp 0 to 7680rpm max

by

volatile int rpmcount; // real rpm

Reply

Rafael November 2, 2015 at 11:15 pm

Thanks! Awesome tutorial! I wanted to know the speed of my bike and adapting this with some functions and math, I can know the speed. Thanks!

Reply

neel stark December 7, 2015 at 8:05 am

wont the ir led need 1.2-1.4 v to run instead of 5v?

Reply

Marcelo Ortiz January 4, 2016 at 2:11 am

Hi, I have a motor with 4 propeller, what do i have to change in the code?

Thanks

Reply

Daniel Fernandes April 18, 2016 at 5:48 pm

I did not understand the question that line: ‘rpm = 30*1000/(miles() – timeold)* rpmcount;’
How would the calculations for a wheel with 15 black marks and 15 white?
Thank you

Reply

Viktor July 21, 2016 at 3:46 pm

Helo

I have a moron question. First time, i put the Vcc cable to the wrong pin (to the led’s ground pin), and i turned on the transmitter. Did i spoiled the recevier? Because the receiver send the 1 for any changes (turn on/turn off the transmitter ) after the correction, what i saw on this page(thanks 🙂 )

Sorry my english 🙂

Reply

Ralph Hulslander September 17, 2016 at 8:05 pm

Errors from your code!!

Arduino: 1.6.11 (Windows 10), Board: “Arduino Nano, ATmega328”

C:\Program Files (x86)\Arduino\arduino-builder -dump-prefs -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Ralph\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10611 -build-path C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp -warnings=all -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Ralph\Documents\Arduino\OPT_Tachometer\OPT_Tachometer.ino
C:\Program Files (x86)\Arduino\arduino-builder -compile -logger=machine -hardware C:\Program Files (x86)\Arduino\hardware -tools C:\Program Files (x86)\Arduino\tools-builder -tools C:\Program Files (x86)\Arduino\hardware\tools\avr -built-in-libraries C:\Program Files (x86)\Arduino\libraries -libraries C:\Users\Ralph\Documents\Arduino\libraries -fqbn=arduino:avr:nano:cpu=atmega328 -ide-version=10611 -build-path C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp -warnings=all -prefs=build.warn_data_percentage=75 -prefs=runtime.tools.avr-gcc.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -prefs=runtime.tools.avrdude.path=C:\Program Files (x86)\Arduino\hardware\tools\avr -verbose C:\Users\Ralph\Documents\Arduino\OPT_Tachometer\OPT_Tachometer.ino
Using board ‘nano’ from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Using core ‘arduino’ from platform in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr
Detecting libraries used…
“C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++” -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino” “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs” “C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp\sketch\OPT_Tachometer.ino.cpp” -o “nul”
“C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++” -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino” “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs” “-IC:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src” “C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp\sketch\OPT_Tachometer.ino.cpp” -o “nul”
“C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++” -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino” “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs” “-IC:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src” “C:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src\LiquidCrystal.cpp” -o “nul”
“C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++” -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino” “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs” “-IC:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src” “C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp\sketch\OPT_Tachometer.c” -o “nul”
“C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++” -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino” “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs” “-IC:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src” “C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp\sketch\OPT_Tachometer.ino.cpp” -o “nul”
Generating function prototypes…
“C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-g++” -c -g -Os -w -std=gnu++11 -fpermissive -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -flto -w -x c++ -E -CC -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino” “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs” “-IC:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src” “C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp\sketch\OPT_Tachometer.ino.cpp” -o “C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp\preproc\ctags_target_for_gcc_minus_e.cpp”
“C:\Program Files (x86)\Arduino\tools-builder\ctags\5.8-arduino10/ctags” -u –language-force=c++ -f – –c++-kinds=svpf –fields=KSTtzns –line-directives “C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp\preproc\ctags_target_for_gcc_minus_e.cpp”
Compiling sketch…
“C:\Program Files (x86)\Arduino\hardware\tools\avr/bin/avr-gcc” -c -g -Os -Wall -Wextra -std=gnu11 -ffunction-sections -fdata-sections -MMD -flto -fno-fat-lto-objects -mmcu=atmega328p -DF_CPU=16000000L -DARDUINO=10611 -DARDUINO_AVR_NANO -DARDUINO_ARCH_AVR “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino” “-IC:\Program Files (x86)\Arduino\hardware\arduino\avr\variants\eightanaloginputs” “-IC:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src” “C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp\sketch\OPT_Tachometer.c” -o “C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp\sketch\OPT_Tachometer.c.o”
OPT_Tachometer.c:17: error: unknown type name ‘byte’

volatile byte rpmcount;

^

In file included from C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:27:0,

from C:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src/LiquidCrystal.h:5,

from C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp\sketch\OPT_Tachometer.c:22:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Printable.h:25:1: error: unknown type name ‘class’

class Print;

^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Printable.h:33:1: error: unknown type name ‘class’

class Printable

^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Printable.h:34:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{‘ token

{

^

In file included from C:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src/LiquidCrystal.h:5:0,

from C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp\sketch\OPT_Tachometer.c:22:

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:34:1: error: unknown type name ‘class’

class Print

^

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/Print.h:35:1: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{‘ token

{

^

In file included from C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp\sketch\OPT_Tachometer.c:22:0:

C:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src/LiquidCrystal.h:45:1: error: unknown type name ‘class’

class LiquidCrystal : public Print {

^

C:\Program Files (x86)\Arduino\libraries\LiquidCrystal\src/LiquidCrystal.h:45:21: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘:’ token

class LiquidCrystal : public Print {

^

OPT_Tachometer.c:24: error: unknown type name ‘LiquidCrystal’

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

^

OPT_Tachometer.c:24: error: expected declaration specifiers or ‘…’ before numeric constant

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

^

OPT_Tachometer.c:24: error: expected declaration specifiers or ‘…’ before numeric constant

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

^

OPT_Tachometer.c:24: error: expected declaration specifiers or ‘…’ before numeric constant

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

^

OPT_Tachometer.c:24: error: expected declaration specifiers or ‘…’ before numeric constant

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

^

OPT_Tachometer.c:24: error: expected declaration specifiers or ‘…’ before numeric constant

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

^

OPT_Tachometer.c:24: error: expected declaration specifiers or ‘…’ before numeric constant

LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

^

C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp\sketch\OPT_Tachometer.c: In function ‘setup’:

OPT_Tachometer.c:36: error: ‘lcd’ undeclared (first use in this function)

lcd.begin(16, 2); // intialise the LCD

^

C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp\sketch\OPT_Tachometer.c:36:4: note: each undeclared identifier is reported only once for each function it appears in

C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp\sketch\OPT_Tachometer.c:40:4: warning: implicit declaration of function ‘attachInterrupt’ [-Wimplicit-function-declaration]

attachInterrupt(0, rpm_fun, FALLING);

^

OPT_Tachometer.c:40: error: ‘FALLING’ undeclared (first use in this function)

attachInterrupt(0, rpm_fun, FALLING);

^

Multiple libraries were found for “LiquidCrystal.h”
C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp\sketch\OPT_Tachometer.c:43:4: warning: implicit declaration of function ‘pinMode’ [-Wimplicit-function-declaration]

Used: C:\Program Files (x86)\Arduino\libraries\LiquidCrystal
pinMode(ledPin, OUTPUT);

Not used: C:\Users\Ralph\Documents\Arduino\libraries\NewliquidCrystal
^

OPT_Tachometer.c:43: error: ‘OUTPUT’ undeclared (first use in this function)

pinMode(ledPin, OUTPUT);

^

C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp\sketch\OPT_Tachometer.c:44:4: warning: implicit declaration of function ‘digitalWrite’ [-Wimplicit-function-declaration]

digitalWrite(ledPin, HIGH);

^

OPT_Tachometer.c:44: error: ‘HIGH’ undeclared (first use in this function)

digitalWrite(ledPin, HIGH);

^

C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp\sketch\OPT_Tachometer.c: In function ‘loop’:

C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp\sketch\OPT_Tachometer.c:54:4: warning: implicit declaration of function ‘delay’ [-Wimplicit-function-declaration]

delay(1000);

^

C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp\sketch\OPT_Tachometer.c:56:4: warning: implicit declaration of function ‘detachInterrupt’ [-Wimplicit-function-declaration]

detachInterrupt(0);

^

C:\Users\Ralph\AppData\Local\Temp\build1048c6d5a27b5c792c2453e8f50cd505.tmp\sketch\OPT_Tachometer.c:60:4: warning: implicit declaration of function ‘millis’ [-Wimplicit-function-declaration]

rpm = 30*1000/(millis() – timeold)*rpmcount;

^

OPT_Tachometer.c:65: error: ‘lcd’ undeclared (first use in this function)

lcd.clear();

^

OPT_Tachometer.c:70: error: ‘FALLING’ undeclared (first use in this function)

attachInterrupt(0, rpm_fun, FALLING);

^

Using library LiquidCrystal at version 1.0.5 in folder: C:\Program Files (x86)\Arduino\libraries\LiquidCrystal
exit status 1
unknown type name ‘byte’

Reply

Maddspud November 11, 2016 at 11:06 pm

So I tried out the tachometer this morning after I finished it and the phototransistor wouldn’t work. I know it works because I performed a few tests on it and it was fine. I’m thinking it was in the way it was hooked up to the arduino. Can someone please help me?

Reply

Lavish November 23, 2016 at 3:35 am

Is it arduino uno or arduino uno R3

Reply

Gayan Perera January 18, 2017 at 11:50 am

i implemented a device slimier to your device ,but the problem is some times rmp value is a very high wrong value . need an advice i have used ir reflective sensor digital output as a interrupt signal .

Reply

Juiwen January 23, 2017 at 1:01 am

Dear Rezz,

First, thanks for your sharing RPM counter tutorial.
I have a question and suggestion that needs your help.
The RPM counter can just count the fixed qty “2 propellers”.
If I want to design a device with buttons to input the quantity of propeller and the value can be showed in the LCD then it can count the correct RPM.
How to modify this program and the layout on PCB?
Another question, how about the IR LED interception rate with your program by now?

Thanks!

BRs!

Juiwen

Reply

PUNEET KUMAR February 6, 2017 at 12:35 am

Sir please tell me which arduino pro mini (3.3V or 5V) is used in digital tachometer.

Reply

PUNEET KUMAR March 16, 2017 at 11:09 am

Sir please tell me external voltage required for arduino rpm counter.

Reply

ateeb April 30, 2017 at 9:50 pm

Hello Sir…!!!
I want to ask that why we have used 10K resistance with the long leg of phototransistor

Reply

Emanuel July 30, 2017 at 1:02 pm

Hello,

Why is interrupt function run twice?

Thanks.

Reply

ali August 9, 2017 at 10:03 pm

What is the accuracy of this RPM Counter?

Reply

Emanuel September 4, 2017 at 3:59 pm

Hello,

Thank you for your project.

I´ll try it.

Reply

Wesley Wong September 7, 2017 at 4:01 am

Hi there,

May i know that is the part number of the 1x IR LED and 1x IR Phototransistor you are using in this project?

Reply

Van Williams November 16, 2017 at 6:40 pm

I just burned out an IR Led powering it through the Arduino. Does it not have this issue when powered from pin 13 without any kind of resistor?

Reply

Thomas Gaspick April 27, 2018 at 6:46 pm

I got the code to verify and upload fine with a Nano. The device sort of works, but the rpm readouts that I get are are WILDLY erratic — no rhyme or reason to them whatsoever. For an input at D2, I’m using a TTL timing signal from a reciprocating electric engine controller. The square wave timing signal signal looks to me to be perfectly good for the application. Any ideas about where I might be going wrong? I’m an Arduino novice, and I have a difficult time making sense of code.

I really like the approach taken here — the ‘once per second’ rpm reading makes for a proper instrument. I’d like to use this as the basis for a small engine tachometer; one that gets its input signal by inductively coupling to the spark plug wire.

Reply

scooby September 15, 2018 at 1:06 pm

Change volatile byte rpmcount to volatile int rpmcount if you want to read higher than 7800 rpm.
change rpm = 30*1000/(millis() – timeold)*rpmcount;
to rpm = 60*rpmcount
or rpm = 30*rpmcount (if you have 2 interrupts per revolution)
change delay(1000) to delay(999)

Reply

Cris. Gem. October 12, 2018 at 5:35 pm

Very interesting. Easy to build.
I use a Hall Effect sensor also.
Thank you.

Reply

Cancel reply

Leave a Comment

Previous post:

Next post: