Arduino Bike Computer

Im trying to debug this code I have written for a bike computer that uses a magnetic REED switch mounted on the wheel to count RPM and display RPM and MPH to a 16x2 LCD. I have everything hooked up but the numbers Im getting are off (also, its displaying numbers when the switch is not being triggered). Ive been through the code but cant find whats wrong. HELP!

int val;
long last=0;
int stat=LOW;
int stat2;
int conuter=0;
int displayrpm;
int milisec=500; // the time it takes each reading

#include <LiquidCrystal.h>

// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

void setup() {
// set up the LCD’s number of columns and rows:
lcd.begin(16, 2);
// Print a message to the LCD.
lcd.print(" MPH RPM");
}

void loop()
{
val=analogRead(A0);
if(val!=LOW){
stat2=HIGH;
}
else{
stat2=LOW;
}
if(stat2!=stat) //state change Counter
conuter++;
stat2=stat;

if(millis()-last>=milisec){
double rpm=((double)conuter)/120000*milisec;
displayrpm=rpm;

lcd.setCursor (2,1); //Print MPH
lcd.print(displayrpm*.0078);
lcd.setCursor (11,1); //Print RPM
lcd.print(displayrpm);
conuter=0;
last=millis();

return;
}

}

Why are using AnalogRead to read the triggering of a REED switch?

if(val!=LOW){

Spacesareagoodthing!

I have tried it with digital write and still no dice. The common port on my reed switch only likes going to ground. How should I hookup the NO port with the 5V and the digital pin so when the switch closes, it returns a high value??

How is the switch hooked to the arduino? Have you left the input pin floating? Are you doing any kind of debouncing? It is a switch after all. I am not familiar with the characteristics of reed switches. It may not need it. My gut says it does. digitalRead() works just fine. Use it. Absolutely no reason to not use it. You'll find those analog inputs more useful reading analog information. Or reading several buttons using a resistor ladder and only one analog pin.

crrTTU: I have tried it with digital write and still no dice. The common port on my reed switch only likes going to ground. How should I hookup the NO port with the 5V and the digital pin so when the switch closes, it returns a high value??

Configure the pin to use its internal pull-up resistor and connect your reed switch. When the switch is not activated, the pin will read HIGH, when the switch is activated it will read LOW... If it doesn't, there is something wrong with your wiring or components.