Last active
December 29, 2019 07:48
-
-
Save yzdann/c87a1d59aed7774f4461f70a76c177d2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "LiquidCrystal.h" | |
#include "Timer.h" | |
Timer Count; | |
// rs, en, d4, d5, d6, d7 | |
LiquidCrystal lcd(8, 9, 4, 5, 6, 7); | |
long rpmcount; | |
const int hallPin = 2; | |
int time_now = 0; | |
void setup() | |
{ | |
pinMode(hallPin,INPUT); | |
lcd.begin(16, 2); | |
lcd.print("RPM: "); | |
lcd.setCursor(0,1); | |
attachInterrupt(digitalPinToInterrupt(hallPin), rpmFunc, RISING); | |
Count.every(5000, rpmCal); | |
} | |
void loop() { | |
Count.update(); | |
} | |
void rpmCal() { | |
lcd.print(rpmcount*2*5); | |
delay(1000); | |
rpmcount = 0; | |
clearLCDLine(1); | |
} | |
void rpmFunc() | |
{ | |
rpmcount++; | |
} | |
void clearLCDLine(int line){ | |
for(int n = 0; n < 12; n++) { | |
lcd.setCursor(n,line); | |
lcd.print(" "); | |
} | |
lcd.setCursor(0,line); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment