## Introduction: DIGITAL TACHOMETER

This is a Digital Tachometer using Hall Effect Magnetic Sensor, Arduino Nano and show the result on 4 Digit 7 Segment Display.

Its very simple project to build.

As you see on circuit diagram, we only need 4 resistors to limit the current for the 7 segment display.

COMPONENTS:

1. ARDUINO NANO V3
2. HALL EFFECT SENSOR MODULE
3. 4 DIGIT 7 SEGMENT DISPLAY (12 PINS)
4. 4 X 330OHM RESISTOR 1/4W 5%

## Step 1: CREATE PCB & CODE

I'm using Fritzing Apps to create a PCB.

The size is about 40mm x 40mm using Single Layer PCB

There are four jumper on PCB.

THE CODE:

```// DIGITAL TACHOMETER// 4 DIGIT 7 SEGMENT DISPLAY
// by SAFT7ROBOTICS.comint sensorvalue;
int state1 = HIGH;
int state2;
float rps;
float rpm;
long prevMillis = 0;
long interval = 200;
long currentTime;
long prevTime = 1;
long diffTime;
int sensorthreshold = 30;//ABCDEFG,dp
const int numeral[10] = {
B11111100, //0
B01100000, //1
B11011010, //2
B11110010, //3
B01100110, //4
B10110110, //5
B00111110, //6
B11100000, //7
B11111110, //8
B11100110, //9
};//pins for decimal point and each segment
//dp, G, F, E, D, C, B, A
const int segmentPins[] = { 4, 7, 8, 6, 5, 3, 2, 9};
const int numberofDigits = 4;
const int digitPins[numberofDigits] = { 10, 11, 12, 13}; //digits 1, 2, 3, 4void setup()
{
//set segment and DP pins to output
for (int i = 0; i < 8; i++)
pinMode(segmentPins[i], OUTPUT);  //sets the digit pins as outputs
for (int i = 0; i < numberofDigits; i++)
pinMode(digitPins[i], OUTPUT);
}void loop()
{
if (sensorvalue < sensorthreshold)
state1 = HIGH;
else
state1 = LOW;
if (state2 != state1) {
if (state2 > state1) {
currentTime = micros();   // Get the arduino time in microseconds
diffTime = currentTime - prevTime;
rpm = 60000000 / diffTime; // calculate how many rev per minute      unsigned long currentMillis = millis();      if (currentMillis - prevMillis > interval) {
prevMillis = currentMillis;
}
showNumber(rpm);
prevTime = currentTime;
}
state2 = state1;
}
}void showNumber (int number)
{
if (number == 0)
showDigit (0, numberofDigits - 1); //display 0 in the rightmost digit
else
{
for (int digit = numberofDigits - 1; digit >= 0; digit--)
{
if (number > 0)
{
showDigit(number % 10, digit);
number = number / 10;
}
}
}
}//Displays given number on a 7-segment display at the given digit position
void showDigit (int number, int digit)
{
digitalWrite(digitPins[digit], HIGH);
for (int segment = 1; segment < 8; segment++)
{
boolean isBitSet = bitRead(numeral[number], segment);    //isBitSet= ! isBitSet; //remove this line if common cathode display
digitalWrite(segmentPins[segment], isBitSet);
}
delay(5);
digitalWrite(digitPins[digit], LOW);
}```

## Step 2: TESTING..

I test this tachometer using computer fan with attached magnet on fan blade.

Finally I put Hall Effect Sensor Module on my Mini Drill Machine, and test the sensor.

Tachometer running well.... YEAY!!