ghost detector not working

Hello, I've recently tried to make the "Ghost detector", and I've followed everything (or so i think) and i keep getting this error message:

Arduino: 1.8.5 (Windows Store 1.8.10.0) (Windows 10), Board: "Arduino/Genuino Uno"

C:\Users\Cole\Documents\Arduino\libraries\EMF_reader\EMF_reader.ino: In function 'void setup()':

EMF_reader:37: error: 'class HardwareSerial' has no member named 'pinMode'

Serial.pinMode(9600);

^

exit status 1
'class HardwareSerial' has no member named 'pinMode'

My code is down below.

thanks!

PS. i figured out the Serial problem, but the lights wont turn on at all. they are all wired right, but it might be because my current antenna is a paperclip. thoughts?

#define NUMREADINGS 25
int senseLimit = 1023;


int probePin = 5;
int val = 0;

int LED1 = 11;
int LED2 = 10;
int LED3 = 9;
int LED4 = 8;
int LED5 = 7;
int LED6 = 6;
int LED7 = 5;
int LED8 = 4;
int LED9 = 3;
int LED10 = 2;
int readings[NUMREADINGS];
int index = 0;
int total = 0;
int average = 0;


void setup() {
// put your setup code here, to run once:
pinMode(2, OUTPUT);
pinMode(3, OUTPUT);
pinMode(4, OUTPUT);
pinMode(5, OUTPUT);
pinMode(6, OUTPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
Serial.pinMode(9600);

for (int i = 0; i < NUMREADINGS; i++)
readings[i] = 0;
} 



void loop() {
// put your main code here, to run repeatedly:
val = analogRead(probePin);
if (val >=1) {
val = constrain(val, 1, senseLimit);


val = map(val, 1, senseLimit, 1, 1023);

total -= readings[index];
readings[index] = val;
total += readings[index];
index = (index + 1);
if (index >= NUMREADINGS) index = 0; 
average = total / NUMREADINGS;
if (average > 50) { 
digitalWrite( LED1, HIGH);
}
else { 
digitalWrite (LED1, LOW);

}

if (average > 150) {
digitalWrite( LED2, HIGH);
}
else { 
digitalWrite( LED2, LOW);
}

if (average > 250)                      {
digitalWrite( LED3, HIGH);
}
else { digitalWrite( LED3, LOW);
} 

if (average > 350) { 
digitalWrite( LED4, HIGH);
}
else{ digitalWrite (LED4, LOW);
}

if (average > 450) { 
digitalWrite( LED5, HIGH);
}
else{ digitalWrite (LED5, LOW);
}

if (average > 550) { 
digitalWrite( LED6, HIGH);
}
else{ digitalWrite (LED6, LOW);
}


if (average > 650) { 
digitalWrite( LED7, HIGH);
}
else{ digitalWrite (LED7, LOW);
}

if (average > 750) { 
digitalWrite( LED8, HIGH);
}
else{ digitalWrite (LED8, LOW);
}


if (average > 850) { 
digitalWrite( LED9, HIGH);
}
else{ digitalWrite (LED9, LOW);
}


if (average > 950) { 
digitalWrite( LED10, HIGH);
}
else{ digitalWrite (LED10, LOW);
}
Serial.println(val);

}

}

Read How to post code properly and then use the </> icon to create [code]...[/code] tags around your code so that it is easier to read - that will also get rid of the italics.

Pete

  1. Go back and edit your post to add code tags. See the "How to use this forum" guide.

  2. Do you know where to look to find all the members of the Serial class? pinMode() is not one of them. I suspect you need begin()

Please have a look at how to post your code.

To print stuff you need the “Serial.begin(9600);” statement in setup.

No idea where the “serial.pinmode(1600) “ comes from as it doesnt appear in your code listing , but that is an illegal command

BTW Ghosts don’t exist

I have fixed this, but it still inst working. Im not getting any error messages, but the thing just wont light up! could it be because my antenna is a paperclip? all my hardware is set up right but it wont detect anything, PLEASE HELP!!!

hammy:
Please have a look at how to post your code.

To print stuff you need the “Serial.begin(9600);” statement in setup.

No idea where the “serial.pinmode(1600) “ comes from as it doesnt appear in your code listing , but that is an illegal command

BTW Ghosts don’t exist

I looked at the board itself and saw something that said "1600" on it and tried it but it didn't work so i replaced it with the original.

You didn't do the code tags properly. You need [code] at the beginning of the code and [/code] at the end. To do that, you can either edit your message and type them yourself, or highlight all of the code and then hit the </> icon.

Pete

el_supremo:
You didn't do the code tags properly. You need [code] at the beginning of the code and [/code] at the end. To do that, you can either edit your message and type them yourself, or highlight all of the code and then hit the </> icon.

Pete

Thanks Pete, I think I got it right his time.

There you go :slight_smile:

Pete

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

BTW

for (int i = 0; i < NUMREADINGS; i++)
readings[i] = 0;

The array was cleared when you defined it.

Hi,
Welcome to the forum.

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html then look down to item #7 about how to post your code.
It will be formatted in a scrolling window that makes it easier to read.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Which analog pin are you using A5?

If so;

int probePin = 5;

Should be;

int probePin = A5;

Then connect pin A5 to gnd then 5V, see if your get min and max readings.

Use a potentiometer to check your input as you may not have a calibrated ghost nearby.

Thanks.. Tom... :slight_smile: