Professional Documents
Culture Documents
Project 1: Tachometer
Project 1: Tachometer
Tachometer
Digital Tachometer
A tachometer is a device that is commonly used to measure the speed
of an engine crankshaft in rotational speed in revolutions per minute
(rpm). The speed is indicated on a dashboard gauge and is used to
help drivers determine how fast they are driving.
12/5/2012
CNA1015
Photo Interrupters
Transmissive Photosensors
Microcontroller Programming by C++
#include <htc.h>
# include "pic.h"
#include "lcd.h"
__CONFIG(XT & WDTDIS & PWRTDIS & BORDIS & LVPDIS & UNPROTECT & MCLREN);
void wait();
void main() {
lcd_init();
lcd_clear();
lcd_goto(0);
while(1){
TMR0=0;
IR_Tx = 1;
wait();
RPM = TMR0*60;
IR_Tx = 0;
DD0 = RPM%10;
// DD0 = mask(DD0);
RPM = RPM/10;
DD1 = RPM%10;
//DD1 = mask(DD1);
RPM = RPM/10;
DD2 = RPM%10;
//DD2 = mask(DD2);
DD3 = RPM/10;
//DD3 = mask(DD3);
ch2 = lookup(DD2);
ch3 = lookup(DD1);
ch4 = lookup(DD0);
lcd_putch(ch2);
lcd_putch(ch3);
lcd_putch(ch4);
lcd_puts(" RPM");
void wait(){
char cha;
switch (numb) {
case 0: cha = '0';
break;
break;
break;
break;
break;
break;
break;
break;
break;
break;
return cha;