Lie Detector Project
I did a lie detector for my summer 2024 robotics project at BlueStamp Engineering. It required me to build a device that would read the skin’s resistance and heart rate, which changes when under stress and possibly during a person’s lying. Some challenges included calibrating the circuit and integrating all components together while integrating the components together was definitely the most remarkable success.
Engineer | School | Area of Interest | Grade |
---|---|---|---|
Henry Y | Sage Hill | Mechanical Engineering | Incoming Sophomore |
Final Milestone
I have worked substantially to the extent that I custom-made a housing for my Arduino UNO R3 and breadboard. I also replaced the old heart rate sensor with a custom-made inbuilt heart rate sensor. Additionally, the 10k ohm potentiometer is upgraded to a 200k ohm potentiometer, which gives much finer adjustments. Thus, these enhance the usability of my lie detector project towards completion both physically and functionally. Integrating new components into the existing circuit, like the heart rate sensor and the 200k ohm potentiometer, was quite a challenge to me. It took so many troubleshooting efforts and coding adjustments before all the devices would work in harmony. But conquering those challenges was my greatest triumph. Indeed, seeing the project evolve and working exactly the way it is intended to has been rewarding. It has taught me the importance of persistence and adaptability in problem-solving.
I have built up a good knowledge base in circuit design, Arduino coding, and practical application of sensors in electronics. Troubleshooting techniques and designing custom housing to give a professional finish at the end of a project were also some of the skills acquired. These skills did not only help me empower myself to complete this lie detector project but also gave me the requisite confidence to tackle more complex projects in the future. This will let me further develop principles learned at BSE and delve deeper into advanced electronics and programming. I would like to learn about more complex sensors and how they can be applied in bigger systems. Furthermore, I am highly interested in learning more about data analysis and machine learning to be able to design more intelligent and responsive devices. I would like to continue to challenge myself with even more ambitious projects that would push my current skill level.
Second Milestone
I have done a lot towards the completion of my project, which is the lie detector. The main work I have done so far is on the technical development of my project. I added a potentiometer in the system so I could adjust and vary the values of resistors. This brings more flexibility and finer adjustment to the circuit, so it’s more sensitive, and thus able to respond to variations in skin resistance. Adding three LEDs, namely green, yellow, and red, was also done to show the indication of voltage values when they increase. These LEDs provide instant, clear indication of possible lies: green if the levels are normal, yellow if they are at a moderate increase, and red if they are at a high increase in voltage. I have also changed the code to support these new features so that the LEDs light accordingly, based on the voltage readings. What has really surprised me about this project is the amount of progress I have made and new techniques that I have tried. I never expected to learn and implement all that in such a short time. It was very rewarding to add new components like the potentiometer and LEDs, making them run together. But more engaging was observing changes in the circuit and its code and their impact on the final functional working and accuracy of the lie detector.
One major challenge that I overcame was adding in the potentiometer. The potentiometer used was a 10k one while the old resistor I was using was 1MΩ. This disparity caused the voltage values to always be very low and hard to get proper readings initially. This meant that I had to tune the circuit and the code to work with these now lower values that this 10k potentiometer was giving, which took some trial and error. By defeating this obstacle, I’ve learned the importance of matching values of components together and the need for tuning in a circuit for optimal performance. There are a few remaining tasks before my final milestone is complete. I will start by adding a heart rate or pulse measurement method so that there could be another signal showing stress or lying. This shall include integrating a heart rate sensor into the existing circuit and updating the code to read and process heart rate data. Second, I will create a house or case for the project to improve the look of the wiring by making sure all of the wiring is hidden, much neater. In so doing, it will give the lie detector professional looks that an end user would want. I will also go back and refine the code and fine-tune the sensors so the lie detector can be as correct and reliable as possible.
First Milestone
For my first milestone, I completed the base construction of a machine and some straps for the fingers showing how changes in resistance in my skin will increase the voltage read and printed by the Arduino. The setup uses a voltage divider circuit wherein the higher the resistance, the more voltage absorbed by the resistor. I wired it all together, using an Arduino UNO R3 to be the brain of the project that would process this data and spit out an output. Additionally, I used a breadboard to straighten everything out and to keep all the components in their correct places, and two finger straps made of Velcro and aluminum foil, connected to the fingers in order to get readings of skin resistance. 1 Megaohm (1MΩ) Resistor was used and crucial for the voltage divider circuit, as it provides the ability to measure skin resistance accurately. The 1MΩ resistor is then put in series with the skin resistance being measured through the finger straps. One end of this setup goes to the 5V pin on the Arduino, and the other to an analog input pin, A0. The midpoint, between the resistor and skin resistance, goes to ground (GND).
During the course of the project, I used a variety of resistor values and had to find the perfect one. I recorded the lowest voltage readings when using resistors of values of lower resistance. This is because it allows more current to flow through them; hence, there will be a lower voltage drop across the resistor. The readings were the highest when I used the 1MΩ resistor. This could be because the higher the resistance, the more it restricts current flow, hence the larger the voltage drop across the resistor. It is the 1MΩ resistor that gave the maximum values obtained so far, hence being the most appropriate for detecting changes in skin resistance. Again, with higher voltage values, I easily noticed changes since these values were more accurate. The higher voltage values gave a finer line of demarcation between the different ranges of skin resistance and thus facilitated the correct detection of a stress response that might indicate lying. In the future I plan to use LEDs to indicate wether the person in fingerstraps if lying or not.
Schematics
Code
const int GSR=A1; // for collecting sensorValue
const int PulseWire = 0;
int Threshold = 550; // for pulse sensor
int threshold=900;
int sensorValue; // Value collected from skin resistence
#define USE_ARDUINO_INTERRUPTS true //Set-up low-level interrupts for most acurate BPM math
#include <PulseSensorPlayground.h> // Includes the PulseSensorPlayground Library
PulseSensorPlayground pulseSensor;
void setup() {
Serial.begin(9600);
pulseSensor.analogInput(PulseWire);
pulseSensor.setThreshold(Threshold);
pinMode(2, OUTPUT); // Green LED
pinMode(3, OUTPUT); // Yellow LED
pinMode(4, OUTPUT); // Red LED
digitalWrite(2, HIGH);
delay(500);
digitalWrite(3, HIGH);
delay(500);
digitalWrite(4, HIGH);
delay(500);
digitalWrite(2, LOW);
delay(500);
digitalWrite(3, LOW);
delay(500);
digitalWrite(4, LOW);
delay(500);
if (pulseSensor.begin()) {
Serial.println("We created a pulseSensor Object !"); // Tells you the pulse sensor is working
}
}
void loop() {
sensorValue=analogRead(GSR); // Uses the A1 to collect the sensorValue
int myBPM = pulseSensor.getBeatsPerMinute();
if (myBPM > 0){ // Only prints the BPM if it is being collected
Serial.print("BPM: ");
Serial.println(myBPM); // Prints your heart rate
}
// All the if statements are for when the LED lights up depending on the user's skin resistence
if (sensorValue > 250){
digitalWrite(4, HIGH);
digitalWrite(3,LOW);
digitalWrite(2,LOW);
Serial.println("User is lying");
}
else{
if(sensorValue > 220){
digitalWrite(4, LOW);
digitalWrite(3, HIGH);
digitalWrite(2, LOW);
Serial.println("User may be lying");
}
else{
if(sensorValue > 100){
digitalWrite(4, LOW);
digitalWrite(3, LOW);
digitalWrite(2, HIGH);
Serial.println("User is not lying");
}
else{
digitalWrite(4, LOW);
digitalWrite(3, LOW);
digitalWrite(2, LOW);
}
}
}
if(sensorValue > 0){ // Only prints sensorValue when the fingerstraps are connected
Serial.print("Voltage: ");
Serial.println(sensorValue);
}
delay(1000); // Sets a delay before the loop runs agian
}
Bill of Materials
Part | Note | Price | Link |
---|---|---|---|
Arduino UNO R3 | Microcontroller board | $27.60 | Link |
Breadboard | For organizing components | $8.99 for 3 | Link |
Potentiometer 200K | Adjusts resistor values | $12.99 for 150 piece kit | Link |
LED lights | Lights up if user is lying | $6.35 for 100 | Link |
Heartrate sensor | Takes users heartrate | $24.99 | Link |
Test Leads | Collects users voltage | $15.99 for a kit | Link |
USB-A Male to USB-B Male | Connecting Arduino Uno R3 to computer | $6.99 for 2 | Link |
Jumper Wires | To connect components | $9.99 for 120 | Link |