help with tachometer code

I have to work on a project that's building a tachometer using arduino and a OHB900 sensor. The sensor works by detecting when a ferrous metal is in between the two plates, and sending a low signal to the arduino. The tachometer is supposed to work with a daisy wheel that has six "petals". Right now I have a code that basically should count when the sensor detects six passes of the petals. When that happens, it marks one rotation. From there I plan to divide the rotations by the amount of time it took to count them to get the rpm. My question is how can I count the amount of time it take for a function to be carried out? Also, my code won't print anything to the serial monitor and I don't know why. Right now, my code should print the array that counts the petals that have passed through, and it should print the array counting the rotations made. My code is pasted below and commented as well as having my problem commented on the bottom. Any insight on either issue would be greatly appreciated. If there's any info I've left out that you need simply ask. Oh, also it's supposed to turn an led on when there's nothing detected and turn it off when the wheel is detected. I don't need help with that but it's a part of the project so I figured it was worth mentioning.

int i, j, k, l, rpm = 0, avg, sum = 0, pin1, petal[6] = {0,0,0,0,0,0}, rotation[20] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} ;
void setup()
{
Serial.begin(9600); //Open serial communications with computer
pinMode(1,INPUT); // sets pin 1 as the input pin from sensor
pinMode(3,OUTPUT); // sets pin 3 as output i.e. LED
}
void loop()
{
pin1 = digitalRead(1); // reads input from sensor
if(pin1 == LOW)
{
digitalWrite(3, LOW); // if the daisy wheel is detected, it sets the LED to off
if(pin1 == LOW)//when one of the petals in the daisy wheel is detected, it will add a 1 to an array
{
for(i = 0; petal == 0; i++)//counts through the array

  • {*
    _ if(petal == 0)//until a zero is detected in one of the 6 places_
    * {*
    _ petal = 1;//and adds a 1 in that spot closing the for loop waiting for another petal to be detected
    * }
    }
    }*_

* if(petal[5] == 1)//if all six petals have passed through the sensor*
* {*
* for (j = 0; j < 5; j++)//prints the array showing that six petals were detected*
* {*
* Serial.println(petal[j]);*
* }*
* for(k = 1; rotation[k] == 0; k++)//counts through the array*
* {*
* if(rotation[k] == 0)//until a zero is detected in one of the 20 places*
* {*
* rotation[k] = k;//then marks the number of rotations that is being detected*
* }*
* }*
* if(rotation[19] == 1)*
* {*
* for (l = 0; l < 19; l++)//prints the array showing that all twenty rotations were detected*
* {*
* Serial.println(rotation[l]);*
* }*
* }*
* }*
* }*
* else*
* {*
* delay(500);//waits half a second to set the led on*
* digitalWrite(3, HIGH);// if the wheel isn't detected, the LED is set to high to light up*
* }*
}

_ /from here I'm not sure what to do. This code should work like this. It counts each petal passing through the sensor, when it counts six_
_ it marks it as one rotation in the rotation array, from there it should count the amount of time it takes for all 20 rotations to happen,
and divide 20 rotations by that amount of time. I have no idea how to count the amount of time from when a certain function in a program starts.
There is the millis() function, but it counts the amount of time from the start of the program, not the start of the rotation counting. maybe an if statement could*
limit the function to only counting the time it takes to gather rotations. not sure yet.*/_

Which arduino are you using? If a uno, pin 1 is the TX pin for hardware serial so there is a conflict. When you set pin 1 to input you disable serial print, I think.

It is the uno board so what you're saying might be the issue. Thanks for the reply.