

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.


Step 1


Step 2


Step 3


Step 4


Step 5


Step 6


Step 7


Step 8


Step 9


Completed



Open 4.3Track alarm.py in Files and click
.
'''
* 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()

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.


Code structure:
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.
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.


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



