Search models, users, collections, and posts
Arduino Nano Tachometer
IP Report
Print Profile(0)
Add the first print profile to earn points
Boost
27
42
0
0
20
1
Released
Description
Warning: The potentiometer on some IR sensors may be in a slightly different position. I used the model of https://grabcad.com/library/hw-201-1. Make sure yours lines up.
Also, please adjust your potentiometer to a known rpm. Some readings may be too high because of debounce. Lower sensitivity until its as low as possile.
Parts are designed to be glued in place.
DESOLDER PINS FROM OLED DISPLAY (removing black header spacer helps a lot). solder directly to pads
Hardware:
Arduino Nano with USB-C port, without headers (i used a chinese knock-off)
128X64 I2C OLED display (white text, 0.96)
IR proximity sensor (one clear led, one black LED.)
Wiring:
IR sensor OUT → D2
Display SDA → A4
Display SCL → A5
Connect all GND together
Connect all 5V together
Code:
#include
#include
#define OLED_RESET -1
Adafruit_SSD1306 display(128, 64, &Wire, OLED_RESET);
#define PULSE_PIN 2
#define DEBOUNCE_US 10000 // debounce threshold in microseconds
volatile unsigned long pulses = 0;
volatile unsigned long lastPulseTime = 0;
unsigned long lastTime = 0;
// Interrupt Service Routine with debounce
void countPulse() {
unsigned long now = micros();
if (now - lastPulseTime > DEBOUNCE_US) {
pulses++;
lastPulseTime = now;
}
}
void setup() {
pinMode(PULSE_PIN, INPUT);
attachInterrupt(digitalPinToInterrupt(PULSE_PIN), countPulse, RISING);
display.begin(SSD1306_SWITCHCAPVCC, 0x3C);
display.clearDisplay();
display.setTextColor(SSD1306_WHITE);
}
void loop() {
if (millis() - lastTime >= 1000) {
noInterrupts();
unsigned long count = pulses;
pulses = 0;
interrupts();
unsigned int rpm = count * 60;
display.clearDisplay();
display.setTextSize(1);
display.setCursor(0, 0);
display.print("RPM:");
display.setTextSize(3);
display.setCursor(0, 20);
display.print(rpm);
display.display();
lastTime = millis();
}
}
License
This user content is licensed under a
Creative Commons Attribution-Noncommercial-NoDerivatives





Comment & Rating (0)