X
Home > Blog > STEM for Arduino > HOW to Make a Track Alarm with Kidspico

HOW to Make a Track Alarm with Kidspico

By r December 12th, 2024 462 views
Track alarm ensures security by detecting pressure. It will remind host when detecting tracks to ensure the safety and property.
In this experiment, we adopt a 8x8 dot matrix and a thin film pressure sensor to form a track alarm. When someone is detected stepping on the sensing area, the dot matrix displays a footprint pattern as a reminder.

Flow

4301

Assembly

line1

Required Parts

Place the pressure sensitive area of the sensor on a firm, flat surface when in use. For details, please refer to Chapter 3.6.

43_00

line1

Step 1

43_01

line1

Step 2

43_02

line1

Step 3

43_03

line1

Step 4

43_04

line1

Step 5

43_05

line1

Step 6

43_06

line1

Step 7

43_07

line1

Step 8

43_08

line1

Step 9

43_09

line1

Completed

43_10

line1

Wiring Diagram

4302

Test Code

Open 4.3Track alarm.py in Files and click 1407.

'''
 * Filename    : Smart Safe Home: Track Alarm
 * Thonny      : Thonny 4.1.4
 * Auther      : http//www.keyestudio.com
'''
from machine import Pin,ADC
import time
from HT16K33 import ht16k33

Pressure = ADC(28)  # thin film pressure sensor

scl = Pin(5) 
sda = Pin(4)
bus = 0

LedArray1 = [0,0,0,1,1,0,0,0,   # footprint
             1,1,0,1,1,0,1,1,
             1,1,0,0,0,0,1,1,
             0,0,0,1,1,0,0,0,
             0,0,1,1,1,1,0,0,
             0,1,1,1,1,1,1,0,
             0,1,1,1,1,1,1,0,
             0,0,1,1,1,1,0,0]

Triaxial = ht16k33(bus, scl, sda)

while True:
    Pressure_value = Pressure.read_u16()
    if Pressure_value < 40000:
        Triaxial.setRotation(0)  # rotation direction
        Triaxial.clear()
        for i in range(8):
            for j in range(8):
                Triaxial.drawPixel(i, j, LedArray1[i*8+j])
        Triaxial.writeDisplay()    
        time.sleep(1)
    else:
        Triaxial.clear()
        Triaxial.writeDisplay() 

Explanations

5top

Conceive:

When someone steps on the pressure sensing area of the sensor, the output analog value of the sensor will decrease.

Set a threshold first to determine whether there is pressure. When the output value is smaller than the threshold, someone steps on this area; If the value is greater than the threshold, no track is detected.

If pressure is detected, a footprint icon will be displayed on the dot matrix.

4303

line2

Code structure:

  1. Initialization.

    Configure I2C, set scl and sda pins, set the pin of the thin film pressure sensor.

    Create an 8*8 array LedArray1 to set the footprint icon.

  2. Loop.

    Determine whether the output analog value is smaller than 40000 (if yes, tracks are detected).

    • analog value < 40000: the dot matrix shows a footprint icon as a reminder.

    • analog value ≥ 40000: the dot matrix displays nothing.

5bottom

Test Result

4top

After uploading code, press the thin film with your finger, and you will see the dot matrix shows a footprint.

4303

4bottom

FAQ
10top
Q: After uploading the code, nothing shows on the matrix when the thin film is pressed?
A: ① The pressure value may be not reach the threshold, so please set a smaller one. ② Try again after pressing the reset button.
10bottom
HOW to Make an Invasion Alarm with Kidspico
Previous
HOW to Make an Invasion Alarm with Kidspico
Read More
How to Program Relay Module on Kidsuno
Next
How to Program Relay Module on Kidsuno
Read More
Message Us