ghost detector not working

Two problems.
The name 'index' is used in one of the libraries and your use of the name conflicts with it. Change all occurrences of 'index' to, for example, 'my_index'.
As @MorganS has pointed out, pinMode is not a member of the Serial class. Change it to Serial.begin(9600)

Pete