Skip to the content.

Lie Detector

Have you ever wanted to test out your friends’ honesty? Now you can with this easy-to-build lie detector. For my project I built a lie detector that lights up whenever it detects that someone may be lying. The only catch are this project’s limitations in the factors in which it takes into account when determining if the user is lying or not, which includes condensation of the skin, and heartrate. Some of my biggest challenges and triumphs were soldering all of the components onto my final board, and coding an algorithm that determines the lighting up of the LED lights for when a “lie” is detected.

Engineer School Area of Interest Grade
Bradley Tsou Carlmont High School Mechanical/Electrical Engineering Incoming Junior

Images of completed project:

- Side view

Untitled drawing

- Top view

Untitled drawing (1)

Modifications

For my modifications, I added a buzzer and a heartrate sensor to my project. The buzzer acts similarly to the LED lights, as it buzzes whenever the lie detector detects a possible lie. The addition of the heartrate sensor was in hopes of increasing the accuracy of the lie detector, as my previous wires - as aforementioned - were somewhat faulty and subject to inconsistancy and less accurate skin/lie readings.

Upon installment of the heartrate sensor, the sensor was proving itself to be effective as it gave largely accurate readings as long as the user’s finger was against the sensor and not making too much movement.

What gave me the most trouble during the “modifications” milestone was trying to install the buzzer. Originally I had just connected the buzzer to the 5V pin, which worked, but would constantly just have the buzzer buzzing. So I decided to connect it to one of the Arduino Nano chip’s digital pins, but what I wasn’t aware of was that the actual chip’s pin was not soldered onto the board correctly. This meant the there was never a connection between the buzzer and the Arduino Nano, which is why it seemingly didn’t work. Fortunately, when I tried switching the connection from pin 9 to pin 8, I realized that it wasn’t a specific pin that was causing the error, but that it just wasn’t soldered properly, and so I fixed it.

Final Milestone

For my third and final milestone I finalized my code and fixed everything into my 3D printed case. I also re-modified my finger wraps to be made out of velcro, aluminum foil, and electrical tape to try and make the readings more accurate - which worked to the extent that there was a barely noticable change in its accuracy. For my code, the main issue was that there were two Serial.print() functions/statements, and I found out that you can only have one Serial.print() statement in a code, or else your values and code will malfunction like mine did.

One small challenge for my 3D case was that the hole for where the arduino cable would go through was slightly offset of where I wanted it to be, so I learned how to dremel and modified it to my liking. Another one of my challenges was trying to get the board to be elevated inside of the case so that the LEDs could poke through their designated hole at the top. Apart from learning how to dremel, I also learned and used a file to make some of the cuts with the dremel more clean and smooth.

Some of my biggest challenges in general I faced during my time at Bluestamp were mainly small minute details, and they taught me how sometimes the most trivial things can play a major role in determining your project’s success and functionability. Some examples included accidentally creating a bridge between two ports or holes when soldering, or missing an end bracket (“}”) in some places in my code, sometimes at the end of a loop or if-statement. For soldering, the more I practiced, the better I got, and for catching errors in my code, I learned how important organization is, especially because even the slightest mistake in the code stopped the entire program from working, and was usually tucked and hidden in a small unexpected place in the hundreds of lines of code that I had.

I feel that I can keep and retain many of the key skills that I learned all at Bluestamp - such as soldering, filing, dremeling, and working with circuitry and breadboards in general - to help me in my future path for engineering. I wish to not only expand my knowledge and experience in a potential future job but also to obtain more engineering skills and hone them down to perfection.

Second Milestone

For my second milestone, I successfully transferred all of my components from my “draft” breadboard to a more professional soldering board. This process was very tedious and was actually much more difficult than I thought, as it was essentially all just soldering and de-soldering. I learned many things through doing this, such as learning new and better ways to solder and de-solder, and just getting better at both in general.

My first main difficulty was dealing with a “faulty” solder board. It took a few tries and hours until I decided to use a new soldering board, since the one I was using would not stick with the solder at all. For example, the solder would be touching a wire and the board, and once you took the soldering iron away, the solder would sometimes just fall off. I was able to de-solder some things, but other components such as the actual Arduino Nano chip itself had to be replaced.

My second main difficulty was a gap in my knowledge of breadboards. I based my breadboard model on a picture that was slightly vague in the instructions, and just blindly copied from the picture. It turns out that the breadboard was flipped upside down when I copied it, so I plugged my ground cable into the positive ground when it should have been in the negative. This caused even more problems in and of itself, as it fried my LEDs, and at the time I did not know why they were frying (I also learned that positive and negative current flow do not go well together!).

What I still need to do before my final milestone is completed is to finish up all my code for the project. Right now, I have a constant number that acts as a range for detecting when someone is “lying”, but now I am trying to implement a code or algorithm that calculates an actual range to detect any lies.

First Milestone

My project is a lie detector, and it functions using an Arduino Nano and the Arduino IDE software. So far I have made a basic breadboard and successfully written some basic code that lights up the LEDs whenever there is a “change” in the input. There are 3 LEDs, a 2k resistor, and 6 wires in total. 3 of the wires go to the 3 LEDs, one acts as a ground cable to connect the LEDs to the Nano chip, and the remaining two are for the user’s finger skin inputs. I also decided to solder some wires onto the Arduino Nano on the breadboard instead of just plugging them in, for some more soldering practice, but this turned out to be much harder than I had thought.

One change that I noticed was that there was a difference in the original description/instructions of the lie detector, and that was that the range of the serial plotter (in voltage) differed depending on who was tested. In the original, the range was from 10-30, for myself it was from 900-1000, and for someone else it was in the 300s.

So far I have hard-coded it to fit my fingers’ range of 900-1000, and I hope to implement a method in the code in which it will automatically detect a lie and won’t have to be hard-coded to tailor an individual person’s fingers. One main struggle that I faced was trying to solder the wires to the Arduino Nano board, especially when they were right next to each other, only millimeters away. This was also especially hard because the soldering iron’s tip was larger/wider than the distances between two pins, so it was very easy to accidentally create bridges in the soldering.

Starter Project

For my starter project I made an LED cat lamp. This project was relatively simple, all it required was for me to assemble the pieces of the lamp such as the body of the cat, and then attached all of the components such as the LED light or photoresister by soldering them onto their correct place. The final part was to put on all the other pieces for extra looks - such as adding the cat’s arms - and installing the battery.

Schematics

lie detector schematics

Code


int bpmcount = 0;
bool tf = true;
bool ft = true;
long count = 0;
long delaycheck = 0;
int const PULSE_SENSOR_PIN = 0;  // 'S' Signal pin connected to A0
int Signal;                      // Store incoming ADC data. Value can range from 0-1024
int Threshold = 550;             // Determine which Signal to "count as a beat" and which to ignore.
const int buzzer = 9;


#define USE_ARDUINO_INTERRUPTS true  // Set-up low-level interrupts for most acurate BPM math.
#include <PulseSensorPlayground.h>   // Includes the PulseSensorPlayground Library.

//  Variables
const int PulseWire = 0;      // PulseSensor PURPLE WIRE connected to ANALOG PIN 0
const int LED = LED_BUILTIN;  // The on-board Arduino LED, close to PIN 13.
//int Threshold = 550;           // Determine which Signal to "count as a beat" and which to ignore.
// Use the "Gettting Started Project" to fine-tune Threshold Value beyond default setting.
// Otherwise leave the default "550" value.

PulseSensorPlayground pulseSensor;

void setup() {
  Serial.begin(9600);
  pinMode(buzzer, OUTPUT);
  pinMode(LED_BUILTIN, OUTPUT);
  pinMode(2, OUTPUT);   // Green LED
  pinMode(6, OUTPUT);   // Yellow LED
  pinMode(11, OUTPUT);  // Red LED
  digitalWrite(2, HIGH);  // Sets all the LEDs to on during "SETUP" to make sure they all work and can light up 
  delay(250);
  digitalWrite(6, HIGH); // the items inside of the parenthasis next to "digitalWrite" represent the pin number it is attatched to, and HIGH/LOW                             tell that the light is either on or off respectively. 
  delay(250);
  digitalWrite(11, HIGH);
  delay(250);
  pulseSensor.analogInput(PulseWire);
  pulseSensor.blinkOnPulse(LED);  //auto-magically blink Arduino's LED with heartbeat.
  pulseSensor.setThreshold(Threshold);

  // Double-check the "pulseSensor" object was created and "began" seeing a signal.
  if (pulseSensor.begin()) {
    Serial.println("We created a pulseSensor Object !");  //This prints one time at Arduino power-up,  or on Arduino reset.
  }
}

void loop() { // this loop is fixed and will repeat over and over again as long as the program is running

  if (ft) {
    Serial.print("Calibrating.");
    ft = false;
    //delay(500);
  }
  if (!ft && bpmcount < 7) {   // checking if ft is false and bpmcount is less than 7
    Serial.print(".");
    digitalWrite(2, LOW);  // Green LED
    digitalWrite(6, LOW);  // Yellow LED
    digitalWrite(11, LOW);
    bpmcount++;
    delay(800);
  }

  if (bpmcount == 51) {   // tests to see when bpmcount reaches 51
    Serial.println(" ");  // this basically skips a line to make things easier to read
    bpmcount++;
  }


  if (pulseSensor.sawStartOfBeat()) {  // Constantly test to see if "a beat happened".
    bpmcount == 50;
    bpmcount++;
    int myBPM = pulseSensor.getBeatsPerMinute();  // Calls function on our pulseSensor object that returns BPM as an "int".                                              // "myBPM" hold this BPM value now.
                                                  //Serial.print("BPM: ");                         // Print phrase "BPM: "
                                                  //Serial.println(myBPM);                         // Print the value inside of myBPM.
    if (myBPM > 108) {  // these if statements check for if the heartrate goes past a certain bpm
      Serial.println("♥  A HeartBeat Happened ! ");
      Serial.print("-------------------------------------------------- LYING: ");
      Serial.print(myBPM);
      Serial.println(" BPM");
      digitalWrite(2, LOW);  // Green LED
      digitalWrite(6, LOW);  // Yellow LED
      digitalWrite(11, HIGH);   // in this case, because the bpm is over 108, "digitalWrite" sets the green and yellow to off and red to on, because                                     a lie is detected
      tone(buzzer, 500);

    } else if (myBPM > 90) { // the "else if" means that if the previous "if" statement is false, then this one will run if it is true. 
      Serial.println("♥  A HeartBeat Happened ! ");
      Serial.print("------------------------------------------------ MAYBE LYING: ");
      Serial.print(myBPM);
      Serial.println(" BPM");
      digitalWrite(2, LOW);   // Green LED
      digitalWrite(6, HIGH);  // Yellow LED
      digitalWrite(11, LOW);
      noTone(buzzer);

    } else {  // "else" runs when all the "if" and "else if" statements are false
      Serial.println("♥  A HeartBeat Happened ! ");
      Serial.print("----------------------------------------------- NOT LYING: ");
      Serial.print(myBPM);
      Serial.println(" BPM");
      digitalWrite(2, HIGH);  // Green LED
      digitalWrite(6, LOW);   // Yellow LED
      digitalWrite(11, LOW);
      noTone(buzzer);
    }
  }
}


CAD Files

Case - Body - BradleyT (1).zip

Case - Lid - BradleyT (1).zip

Bill of Materials

Part Note Price Link
Arduino Nano The main component for the project, the microcontroller/chip ~$25 Link
LED lights Lights up when detects lie or vice versa $12 for 450 Link
Male to Male wires Connects all the components on the board $6.50 for 80 Link
Heartrate sensor Sensor for heartrate upon touch with skin $25 Link
2k resistor Helps to regulate current in circut $5.50 for 100 Link
Soldering kit Used to solder everything together, comes with de-solderer, soldering wire, tweezers, and customizable solder tips $50 Link
Gikfun solderable board The base for the components $10 for 5 Link