void loop () {
while (digitalRead(14)==HIGH) {} //spin til no tach pulse
while (digitalRead(14)==LOW) {} //spin til 1st tach pulse begins
unsigned long pulse1=millis(); //track time when 1st pulse begins
while (digitalRead(14)==HIGH) {} //spin til 1st tach pulse ends
while (digitalRead(14)==LOW) {} //spin til next tach pulse begins
unsigned long pulse2=millis();
int rpms=30000/(pulse2-pulse1);
Serial.print(rpms);
}
I actually don't think so. The value's not critical but the electrolytic caps would be way too big. If you're in a radio shack sometime just look for a small ceramic cap. Just leave it out for now and let's try to get it working.I currently do not have a 100 pf cap. only a 100v .1uf, 50v 1.0uf and 10v 100uf.
Will any of those work?
David
#include <LiquidCrystal.h>
LiquidCrystal lcd(8, 11, 7, 6, 5, 4, 3);
void setup()
{
//attachInterrupt(0, tachPulse, RISING);
//time = millis();
}
void loop () {
while (digitalRead(14)==HIGH) {} //spin til no tach pulse
while (digitalRead(14)==LOW) {} //spin til 1st tach pulse begins
unsigned long pulse1=millis(); //track time when 1st pulse begins
while (digitalRead(14)==HIGH) {} //spin til 1st tach pulse ends
while (digitalRead(14)==LOW) {} //spin til next tach pulse begins
unsigned long pulse2=millis();
int rpms=30000/(pulse2-pulse1);
//Serial.print(rpms);
lcd.clear();
lcd.print(rpms);
}
bingo - just toggling it by hand will bounce like mad and give erratic results. You could try the tach now if it's convenient.I did the 12v to 0v then back again a couple times and got -1 and sometimes 6000. 14, 30000, 144....
David
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
S | ATmega168 Beginner MCU Help | Microcontrollers | 8 | |
W | FM Receiver Breakout with ATmega168 | Microcontrollers | 0 | |
R | help with ATmega168 programmer board | Programming & Languages | 21 | |
S | ATMega168 Tachometer help | Microcontrollers | 1 | |
S | ATMega168 Tachometer help using LM2907 chip | Microcontrollers | 70 |
by Jake Hertz
by Jake Hertz
by Jake Hertz