manodeep
Published © Apache-2.0

Digital Tachometer using IR Sensor

DIY digital tachometer using IR Sensor and Arduino(No display, output shows on serial monitor).

BeginnerFull instructions provided7,830
Digital Tachometer using IR Sensor

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
IR Proximity Sensor
Digilent IR Proximity Sensor
×1
Jumper wires (generic)
Jumper wires (generic)
×1
Breadboard (generic)
Breadboard (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Tachometer with IR Sensor

Code

Tachometer with IR Sensor

Arduino
#include <Arduino.h>
#include <SPI.h>
#include <Wire.h>
unsigned long rpmtime;
float rpmfloat;
unsigned int rpm;
bool tooslow = 1;

void setup() {
  Serial.begin(9600);
  TCCR1A = 0;
  TCCR1B = 0;
  TCCR1B |= (1 << CS12); //Prescaler 256
  TIMSK1 |= (1 << TOIE1); //enable timer overflow
  pinMode(2, INPUT);
  attachInterrupt(0, RPM, FALLING);
}

ISR(TIMER1_OVF_vect) {
  tooslow = 1;
}

void loop() {
  delay(1000);
  if (tooslow == 1) {
    Serial.println("Too Slow");
  }
  else {
    rpmfloat = 120 / (rpmtime/ 31250.00);
    rpm = round(rpmfloat);
    Serial.println("RPM = ");
    Serial.println(rpm);
  }
}

void RPM () {
  rpmtime = TCNT1;
  TCNT1 = 0;
  tooslow = 0;
}

Credits

manodeep

manodeep

0 projects • 4 followers

Comments