am using an ir sensor with a +pin , a -pin and a output pin
i tried many codes to get the output with lcd ......pls help me with a code
pls help me with a code
That's not the way it works. You post your non-working code, and we help you understand why it doesn't work, and how to fix it.
volatile byte rpmcount = 0;
unsigned long rpm = 0;
unsigned long timeold = 0;
int interrupt = 0;
sen_analog=A0;
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 9, 10, 11, 12, 13);
void setup()
{lcd.begin(16, 2);
Serial.begin(9600);
attachInterrupt(interrupt,rpmtrigger,FALLING);
}
void loop()
{
if (rpmcount >= 20)
{
rpm=((15000)/(millis()-timeold))*rpmcount;
timeold = millis();
int time = (millis()/1000);
int timedec = (millis()% 1000);
rpmcount = 0;
lcd.print("RPM = ");
lcd.print(rpm);
lcd.print(" Time = ");
lcd.print(time);
lcd.print(".");
lcd.print(timedec);
lcd.println();
}
}
void rpmtrigger()
{
rpmcount++;
}
And we also get very, very upset with people who post the same question in different parts of the forum.
This is called cross-posting and we hate it because IT WASTES TIME.
Cross-post deleted.
Edit: . . . and we also hate it when people don't read the simple posting guidelines displayed at the top of every section of the forum.
It hasn't started well, has it?
i have posted my code sir
tanveer:
i have posted my code sir
You have posted it without using code tags. Did you read the posting guidelines at the top of the forum?
unsigned long rpm = 0;
If you are expecting rpm values greater than 32, 767, you are dreaming.
rpm=((15000)/(millis()-timeold))*rpmcount;
Magic numbers don't cut it.
timeold = millis();
int time = (millis()/1000);
int timedec = (millis()% 1000);
rpmcount = 0;
You've got a shitload of slow stuff going on before you reset rpmcount. Hope that +/- 50% is good enough.
So, what is the problem with the code?