time between to highs?

Hi guys, just want to say that I am working on a school project and I need to finish this project in 12 hours, so any help would be really appreciated. I am currently making a speedometer for my gocart project, where I use an infrared sensor. I tried to calculate the two high's by using duration, but it doesn't seem to work. I am new to this, so any help will be appreciated. The code looks like this: http://imgur.com/g6ynURo Also I have a wire going from pin 8 to pin 9 with 146 ohm resistor. I changed pin1= HIGH and pin1= low to digitalwritelow(pin,high) and the other way around but it still doesn't help and I get a bunch of 0's A help would be really much appreciated and maybe save a high school student.

Guys, this is really important as it is currently 2 am here and I need to finish this project. If you guys helped me you will literally save a life

Samilesma:
I changed pin1= HIGH and pin1= low to digitalwritelow(pin,high) and the other way around but it still doesn’t help and I get a bunch of 0’s

None of that sounds anything like legal code.

Try posting your code here so we can see what we’re working with. Put it in code tags (the little scroll looking thing above the smileys that has <> on it.

Samilesma:
Guys, this is really important as it is currently 2 am here and I need to finish this project. If you guys helped me you will literally save a life

It’s not our fault you waited until the last minute. Please try to remember that.

As Delta_G said...

If you are in a hurry to get our help, show us your code.

.

Samilesma: Hi guys, just want to say that I am working on a school project and I need to finish this project in 12 hours, so any help would be really appreciated. … Guys, this is really important as it is currently 2 am here and I need to finish this project. If you guys helped me you will literally save a life

Oh man, you have so much growing up to do! Permit me to recommend the classic text "How to Win Friends and Influence People".

Heh, to be back in school and slack off till the last minute.

If it wasn't for the last minute, nothing would ever get done.

<int pin = 8;
int pin1 = 9;
unsigned long duration;

void setup()
{
pinMode(pin, INPUT);
pinMode(pin1, OUTPUT);
Serial.begin(9600);

}

void loop()
{
int sensorValue = analogRead(A0);
int omk = 63;
float voltage = sensorValue * (5.0 / 1023.0);
if (voltage > 3){
digitalWrite(pin1, HIGH);
}
else{
digitalWrite(pin1, LOW);
}
duration = pulseIn(pin1, HIGH);
Serial.println(duration/omk);

delay(10);
}>

This is the code

where I use an infrared sensor. I tried to calculate the two high's by using duration

How is the sensor wired? What do you mean by "I tried to calculate the two high's by using duration" ? Can you draw us a signal sketch showing what you are trying to measure? We also need to see a sketch of your circuit.

I schmatic view, hope it helps.

Delta_G:
Put it in code tags (the little scroll looking thing above the smileys that has <> on it.

If you can’t follow directions any better than this, you’re going to fail.