ESP with seriell Monitor

Hello all together,

I`m triying to get the Impuls of a reed contact out of my ESP (over Seriell Monitoring )
It is possible with this code on the Ardoino Uno, but it doesn´t work with the ESP.
What is my mistake ???
I tried already to change the unsigned Long to unsigned int… But that wasn´t the reason.

Here is the Code:

//------------------------
// Impulszähler
// Gibt die Impulse pro Sekunde
// des Spannungsignals an Pin 7 aus
//-------------------------
int pin = 1;
unsigned long N; //Anzahl der Impulse
unsigned long T; //Zeitintervall in us
unsigned long time; //Startzeit
const byte pinLedgruen = 2;
const byte pinLedblau = 3;
const byte pinLedrot = 4;
int Variabel = 5;

void setup(){
Serial.begin(9600);
pinMode(pin, INPUT);
pinMode(pinLedgruen, OUTPUT);
pinMode(pinLedblau, OUTPUT);
pinMode(pinLedrot, OUTPUT);
pinMode (Variabel, OUTPUT);
T = 1e6;
}

void loop(){

N = 0;
time = micros();
do{
if (pulseIn(pin, HIGH)>0) N++;
}
while( micros() < (time+T) );
Serial.println(N);

void zeige_Drehzahl (unsigned long N, unsigned int intervall);
{
static unsigned long last_ms = 0;
unsigned long ms = millis();

if ( N <= 3 ){
digitalWrite (pinLedgruen, HIGH );
}
else {
digitalWrite (pinLedgruen, LOW );
}
if ((N >3)&&(N <=17)) {
digitalWrite (pinLedblau, HIGH );
}
else {
digitalWrite (pinLedblau, LOW );

if ((N >17)&&(N <=200)){
digitalWrite (pinLedrot, HIGH );
}
else {
digitalWrite (pinLedrot, LOW );
}
}
}}

Does this print anything?

void setup(){
  Serial.begin(9600);
  pinMode(pin, INPUT);
  pinMode(pinLedgruen, OUTPUT);
  pinMode(pinLedblau, OUTPUT);
  pinMode(pinLedrot, OUTPUT);
  pinMode (Variabel, OUTPUT);
  T = 1e6;
Serial.println( "I am printed!" );
}

Have you got a pulldown resistor on the input to keep it in a known state ?