Arduino Projects

Create a lie detector with the Arduino Uno

Pinocchio

You are not quite sure if you are being fibbed at the moment? Then it’s time for your own little lie detector. All your test person has to do is pick up two wires and answer your questions – and you know whether he or she is lying or not.

With this project you will of course not really find out if you are being lied to. After all, even “professional” lie detectors are not capable of reliably bringing the truth to light. But for a little fun among friends it is enough! ­čÖé

Beginner

1 hour

about $5 plus costs for the Arduino Uno

For this project you need (quantities see description):

Angebot
ARDUINO UNO REV 3 [A000066]
Arduino Uno ist weltweit die am h├Ąufigsten verwendete und dokumentierte Platine
18,24 EUR
10 St├╝ck Metallschichtwiderst├Ąnde 1/4 Watt - 220 Ohm
10 St├╝ck Metallschichtwiderst├Ąnde 1/4 Watt - 220 Ohm; Dauerspannung max.: 250 V |...
1,73 EUR
10 St├╝ck Metallschichtwiderst├Ąnde 1/4 Watt - 10 kOhm
10 St├╝ck Metallschichtwiderst├Ąnde 1/4 Watt - 10 kOhm; Dauerspannung max.: 250 V |...
1,68 EUR
KINGSO 500 St├╝ck 5mm LED Leuchtdioden Dioden set Elektronik komponenten rund 5 Farben(100er Jede Farbe)
KINGSO LEDs ist Energieeffizient & hochwertige, Bitte seien Sie versichert zu kaufen.
9,99 EUR
AZDelivery Breadboard Kit - 3x Jumper Wire m2m/f2m/f2f + 3er Set MB102 Breadbord inklusive E-Book!
Ôťö´ŞĆ Steckbrett f├╝r schnellen Aufbau elektronischer Schaltungen mit 830 Kontakten.;...
9,99 EUR

How the lie detector works

This project is not complicated: You put 3 LEDs in a circuit to show you how “close to the truth” an answer is. The second circuit is closed by your test person picking up two cables.

Depending on how much the person sweats on their fingers, the lower the skin resistance. You can measure these small differences and track them in your serial plotter. Let us assume that the test person starts to sweat when lying: The resistance of the skin decreases and it becomes more conductive – the measured value increases. If the fingers remain dry, the flowing current is exposed to greater resistance – and the measured value remains low.

The set up

The finished project should look something like this:

Connect the cathodes (short leg) of the three LEDs to the “minus bar” of your breadboard, to GND. Then connect the anodes (long leg) – with intermediate 220╬ę resistors – to the digital pins 2 to 4: green to 2, yellow to 3 and red to 4.

The other circuit that your test person has to close with their fingers is interesting. Here you connect a cable (the red one in the picture) to 5V. The other one goes into the analog pin A0 (purple). Then you leave one pin free on your breadboard and plug another cable into the next pin (also violet above). Into the free pin comes a 10k╬ę resistor, which you connect with the GND (in the picture the black cable).

The latter is a so-called pull-down resistor. It makes sure that your Arduino reads LOW (zero) at pin A0 until the circuit is closed. If you would not install a pull-down resistor, all possible values would be read out. As soon as your test person closes the circuit, the measurement starts.

The code for your lie detector

There are no big surprises in your sketch. In the function void setup() you first start your serial plotter and set the pinModes of the pins for the LEDs:

void setup()
{
  Serial.begin(9600);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
 
}

Afterwards someif/else-statementsin the loop:

void loop()
{
  if (analogRead(A0) > 12)
  {
    digitalWrite(4, HIGH);
  }
  else
  {
    digitalWrite(4, LOW);
  }
  if (analogRead(A0) > 4)
  {
    digitalWrite(2, HIGH);
  }
  else
  {
    digitalWrite(2, LOW);
  }
  if (analogRead(A0) > 9)
  {
    digitalWrite(3, HIGH);
  }
  else
  {
    digitalWrite(3, LOW);
  }

  Serial.println(analogRead(A0));
  delay(20);
}

Here you can control your LEDs: If the measured value is greater than 12, the red LED goes on – otherwise it remains off. The same applies to the other LEDs for the values 9 and 4. Please note: You might have to experiment a bit with these values in your sketch, so that the LEDs light up properly.

In the last two lines you use Serial.println() to output the measured value to the plotter. And the final delay makes sure that a measurement is taken every 20 milliseconds.

And that was it! Find a suitable test person and start your interrogation! ­čÖé Here is the whole sketch to copy out:

void setup()
{
  Serial.begin(9600);
  pinMode(2, OUTPUT);
  pinMode(3, OUTPUT);
  pinMode(4, OUTPUT);
 
}

void loop()
{
  if (analogRead(A0) > 12)
  {
    digitalWrite(4, HIGH);
  }
  else
  {
    digitalWrite(4, LOW);
  }
  if (analogRead(A0) > 4)
  {
    digitalWrite(2, HIGH);
  }
  else
  {
    digitalWrite(2, LOW);
  }
  if (analogRead(A0) > 9)
  {
    digitalWrite(3, HIGH);
  }
  else
  {
    digitalWrite(3, LOW);
  }

  Serial.println(analogRead(A0));
  delay(20);
}

What’s next?

You can easily extend your project: Use e.g. a display instead of the LEDs to display the measured values. Or you can use a servo motor to show you truth or lie with a pointer.

Letzte Aktualisierung am 2020-11-26 / Affiliate Links / Bilder von der Amazon Product Advertising API

You may also like

Comments are closed.