Micro:bit Lie Detector

About the project

With this machine, the truth will never escape you! As long as you can make your subject hold a moisture sensor for a while.

Project info

Items used in this project

Hardware components

BBC micro:bit - An Educational & Creative Tool for Kids BBC micro:bit - An Educational & Creative Tool for Kids x 1
EF Octopus Breakout Board EF Octopus Breakout Board x 1
MOISTURE SENSOR GADGETEER MODULE MOISTURE SENSOR GADGETEER MODULE x 1
EF Octopus OLED EF Octopus OLED x 1
Micro USB cable Micro USB cable x 1

Software apps and online services

Micro:Bit Scratch Editor Micro:Bit Scratch Editor

Story

Goals

  • Get to know the Octopus LED and Soil Moisture Sensor
  • Learn basic statistics
  • Make something using the moisture sensor

Step 1 Components

First of all, plug in the soil moisture sensor. Match the colors and note down what pin you plug for it will influence later procedures.

Next, plug in the Octopus LED. Any of the three slots should do.

Step 2 Pre-Coding

We’ll need to add a package of code to be able to use our kit components. Click on “Advanced” in the Code drawer to see more code sections and look at the bottom of the Code Drawer for “Add Package”.

This will open a dialog box. In “Add Package” text field search tinker kit.

Note: If you get a warning telling you some packages will be removed because of incompatibility issues, either follow the prompts or create a new project in the Projects file menu.

Step 3 Coding

First of all, initialize the OLED using blocks in the OLED section as shown in the picture.

This part of the code allows the soil moisture sensor to measure and record down the electrical conductivity between the two fingers every few seconds for about a minute. Then, it calculates the average. This is the “calm” value when the user has not told any lies.

This part of the code calculates the standard deviation of the readings obtained in that first minute. The standard deviation indicates how different the readings were. A larger standard deviation means more variance in the readings. The “Math.sqrt” block square roots the given value and was added in Javascript.

After the initial readings have been made and recorded, the moisture sensor now measures the average electrical conductivity over five seconds. If it is higher than the average added to the standard deviation, we can conclude that the user has an abnormally high electrical conductivity and is thus lying. Then, the LED screen would show an “X”shape.

To relieve your tired fingers, you can download the code below.

https://makecode.microbit.org/_fadAyyh27Eo3

Credits

Photo of ElecFreaks

ElecFreaks

ElecFreaks is an open design house founded in March 2011. Now we are committed ourselves to Micro:Bit products, hope providing best products for students and educators.

   

Leave your feedback...