First.
Do you have a 555 chip in astable mode to test your code ?
int sensor = 12;
unsigned long highTime;
float totalTime; // Notice float here
float frequency; // <----- Notice float here
void setup()
{
Serial.begin(9600); //begin serial communication
pinMode(sensor,INPUT);
}
void loop()
{
highTime = pulseIn(sensor, HIGH); //find time the pin goes high.
// let me re-phrase that
// totalTime = ( float( highTime ) * 2.0 ) / 1000.0; // <-- the correct way
// I did that what is written , and I end up nothing.
// The incorrect way
totalTime = highTime*2/1000; //total time is highTime*2 because you need
//to complete a whole wave cycle. Then divide by
//1000 to get seconds from milliseconds
// let me re-phrase that
// frequency = 1.0 / totalTime; // Correct way
frequency = 1/totalTime; //convert period to frequency by inversing it.
// Let me re-phrase that
// Serial.println( frequency, 3 ); // < -- Display 3 decimal point.
Serial.println(frequency); //print frequency to Serial monitor.
delay(1000); //wait a second.
}