GHOST HUNTING EQUIPMENT

FREE to download

By all means download the Arduino code for the three DIY ghost hunting equipment builds. Unfortunately we do not have the schemetics at this time, but we will endevour to try and locate them for you.

Hopefully you can make sense of the code!

DOHX Ultra-Sonic Sensor

IR Coffin Music Box

FM Based Spirit Box

Ghost Hunting – Pre-formatted Code

const int trig = 12;
const int echo = 13;
const int trig1 = 8;
const int echo1 = 9;

const int LED1 = 8;
const int LED2 = 7;
const int LED3 = 6;
const int LED4 = 5;
const int LED5 = 4;
const int LED6 = 3;
const int LED7 = 2;
const int buzzer = 11;

int duration = 0;
int distance = 0;
int duration1 = 0;
int distance1 = 0;
int safetyDistance;

void setup()
{

pinMode(trig , OUTPUT);
pinMode(echo , INPUT);
pinMode(trig1 , OUTPUT);
pinMode(echo1 , INPUT);
pinMode(LED1 , OUTPUT);
pinMode(LED2 , OUTPUT);
pinMode(LED3 , OUTPUT);
pinMode(LED4 , OUTPUT);
pinMode(LED5 , OUTPUT);
pinMode(LED6 , OUTPUT);
pinMode(LED7 , OUTPUT);

Serial.begin(9600);

}

void loop()
{
digitalWrite(trig , HIGH);
delayMicroseconds(10);
digitalWrite(trig , LOW);

duration = pulseIn(echo , HIGH);
distance = (duration/2) / 28.5 ;
Serial.println(distance);

if ( distance <= 7 )
{
digitalWrite(LED1, HIGH);

}
else
{
digitalWrite(LED1, LOW);

}
if ( distance <= 14 )
{
digitalWrite(LED2, HIGH);
}
else
{
digitalWrite(LED2, LOW);
}
if ( distance <= 21 )
{
digitalWrite(LED3, HIGH);
}
else
{
digitalWrite(LED3, LOW);
}
if ( distance <= 28 )
{
digitalWrite(LED4, HIGH);
}
else
{
digitalWrite(LED4, LOW);
}
if ( distance <= 35 )
{
digitalWrite(LED5, HIGH);
}
else
{
digitalWrite(LED5, LOW);
}
if ( distance <= 42 )
{
digitalWrite(LED6, HIGH);

}
else
{
digitalWrite(LED6, LOW);

}
if ( distance <= 49 )
{
digitalWrite(LED7, HIGH);
pinMode(buzzer, OUTPUT);
tone(buzzer,1000);

}
else
{
digitalWrite(LED7, LOW);
pinMode(buzzer,0);
}

digitalWrite(trig1 , HIGH);
delayMicroseconds(10);
digitalWrite(trig1, LOW);
duration1 = pulseIn(echo1 , HIGH);
distance1 = (duration1/2) / 28.5 ;
Serial.println(distance1);

if ( distance1 <= 7 )
{
digitalWrite(LED1, HIGH);

}
else
{
digitalWrite(LED1, LOW);

}
if ( distance1 <= 14 )
{
digitalWrite(LED2, HIGH);
}
else
{
digitalWrite(LED2, LOW);
}
if ( distance1 <= 21 )
{
digitalWrite(LED3, HIGH);
}
else
{
digitalWrite(LED3, LOW);
}
if ( distance1 <= 28 )
{
digitalWrite(LED4, HIGH);
}
else
{
digitalWrite(LED4, LOW);
}
if ( distance1 <= 35 )
{
digitalWrite(LED5, HIGH);
}
else
{
digitalWrite(LED5, LOW);
}
if ( distance1 <= 42 )
{
digitalWrite(LED6, HIGH);

}
else
{
digitalWrite(LED6, LOW);

}
if ( distance1 <= 49 )
{
digitalWrite(LED7, HIGH);
pinMode(buzzer, OUTPUT);
tone(buzzer,1000);

}
else
{
digitalWrite(LED7, LOW);
pinMode(buzzer,0);
}
}
#include <AFMotor.h>
AF_DCMotor motor(4);
int ir = 2;
int x;
int led = A0;

void setup() {
Serial.begin(9600);
pinMode(2, INPUT);
//Set initial speed of the motor & stop
motor.setSpeed(160);
motor.run(RELEASE);
}

void loop() {
uint8_t i;

x = digitalRead(ir);
Serial.println(x);

if (x == 0) //Sensor activate
{
digitalWrite(A0, HIGH);
motor.run(FORWARD);
// Accelerate from zero to maximum speed
for (i = 0; i < 255; i++) {
motor.setSpeed(160);
}
} else //Sensor Activated[when x is 0]
{
digitalWrite(A0, LOW);
motor.run(RELEASE);
delay(1000);
}
}
#include <Wire.h>

#include <TEA5767.h>

#include <LiquidCrystal.h>

#define TEA5767_I2C_ADDR 0x60  // TEA5767 I2C address

TEA5767 radio = TEA5767();

//LCD pin to Arduino

const int pin_RS = 8;

const int pin_EN = 9;

const int pin_d4 = 4;

const int pin_d5 = 5;

const int pin_d6 = 6;

const int pin_d7 = 7;

const int pin_BL = 10;

int speed = 0;

int dw = 100;

int maxWait = 1000;

LiquidCrystal lcd( pin_RS,  pin_EN,  pin_d4,  pin_d5,  pin_d6,  pin_d7);

int R = 0;

int U = 0;

int D = 0;

int L = 0;

void setup() {

  Serial.begin(9600);

  Wire.begin();

  lcd.begin(16, 2);  // Initialize the LCD

  lcd.clear();

  lcd.setCursor(0,0);

  lcd.print("Days of Horror");

  lcd.setCursor(0,1);

  lcd.print("SBox V2.1 (2023)");

  delay(1500);

  lcd.clear();

  lcd.setCursor(0,0);

  lcd.print("Set Sweep :");

  lcd.setCursor(0,1);

  lcd.print(speed);

  delay(10);




  // Initialize TEA5767

  initializeTEA5767();

    int x;

  x = analogRead (0);

}

void loop() {

  int x;

  x = analogRead (0);




  if (x < 60) {

    R = 1; //Right;

    // Scan through all FM frequencies from highest to lowest

  do

  for (float frequency = 87.5; frequency <= 108.0; frequency += 0.1) {

    setFrequencyTEA5767(frequency);

    displayFrequency(frequency);

    delay(speed); // Adjust delay as needed for your scanning speed

    U = 0;

    D = 0;

    L = 0;

  }

 while (1);

 }

 if (x >= 60 and x < 200) {

      // "Up" button

       // Increase the number by 10

       if (speed > 90)

         speed = 100;

        else

       speed += 10;

  lcd.setCursor(0,0);

  lcd.print("Sweep Set :");

  lcd.setCursor(0,1);

  lcd.print("    ");

  lcd.setCursor(0,1);

  lcd.print(speed);

  delay(300);

 }

  else if (x < 400) {

    // "Down" button

    if (speed < 10 )

      speed = 0;

    else  // Decrease the number by 10

    speed -= 10;

  lcd.setCursor(0,0);

  lcd.print("Sweep Set :");

  lcd.setCursor(0,1);

  lcd.print("    ");

  lcd.setCursor(0,1);

  lcd.print(speed);

  delay(300);

}




  else if (x < 600) {

    L = 1; //Left;

    do

    for (float frequency = 108.0; frequency >= 87.5; frequency -= 0.1) {

    setFrequencyTEA5767(frequency);

    displayFrequency(frequency);

    delay(speed); // Adjust delay as needed for your scanning speed

    R = 0;

    D = 0;

    U = 0;

  }

  while (1);

  }

    else if (x >= 600 and x < 800){

    D = 1; //Select;

  // Generate and scan random FM frequencies

  do

  for (int s = 0; s < 10; s++) {  // Adjust the number of random frequencies as needed

    float frequency = random(875, 1080) / 10.0;  // Generate random frequency

    setFrequencyTEA5767(frequency);

    displayFrequency(frequency);

    delay(speed);  // Adjust delay as needed for your scanning speed

  }

  while (1);

  }

}

void initializeTEA5767() {

  Wire.beginTransmission(TEA5767_I2C_ADDR);

  Wire.write(0x80); // Command to reset TEA5767

  Wire.endTransmission();

  delay(130);

}

void setFrequencyTEA5767(float frequency) {

  uint16_t frequencyB = (frequency * 1000000 + 225000) / 8192;

  uint8_t frequencyH = frequencyB >> 8;

  uint8_t frequencyL = frequencyB & 0xFF;

  Wire.beginTransmission(TEA5767_I2C_ADDR);

  Wire.write(0x60 | frequencyH); // Set high byte of frequency

  Wire.write(frequencyL);        // Set low byte of frequency

  Wire.write(0xB0);               // Command to set frequency

  Wire.write(0x10);               // Disable mute and search mode

  Wire.endTransmission();

  delay(100);

}

void displayFrequency(float frequency) {




if (R == 1) {

     lcd.clear();

     lcd.setCursor(0, 0);

    lcd.print("Speed : ");

    lcd.setCursor(8,0);

    lcd.print(speed);

     lcd.setCursor(0, 1);

     lcd.print(frequency, 1);

}

else if ( L ==1 ) {




     lcd.clear();

     lcd.setCursor(0, 0);

    lcd.print("Speed : ");

    lcd.setCursor(8,0);

    lcd.print(speed);

     lcd.setCursor(0, 1);

     lcd.print(frequency, 1);

 }

  else if (D == 1) {




    lcd.clear();

     lcd.setCursor(0, 0);

    lcd.print("Speed : ");

    lcd.setCursor(8,0);

    lcd.print(speed);

     lcd.setCursor(0, 1);

     lcd.print(frequency, 1);

}

 }