Example Code for UNIHIKER-Python Data Display
Connect the sensor to hardware port P21 on the UNIHIKER, and then display the data detected by the sensor on the UNIHIKER.
Hardware Preparation
- 1 x UNIHIKER
- 1 x Linear/Analog Hall Sensor
- 1 x Two-end PH2.0-3P White Silicone Twisted Wire
Software Preparation
- Python IDE
Wiring Diagram

Other Preparation Work
Sample Code
# -*- coding: UTF-8 -*-
# MindPlus
# Python
from unihiker import GUI
u_gui=GUI()
text=u_gui.draw_text(text="real-time data:",x=20,y=40,font_size=12, color="#000000")
value = 0
data_display =u_gui.draw_text(text=value,x=130,y=40,font_size=12, color="#000000")
while True:
value = 1623
data_display .config(text=value)
Note: You can refer to the MindPlus Code Programming Tutorial for a better understanding of how to use Python code mode in MindPlus.
Result
When the S pole of the magnet faces the sensor detection area, the indicator light on the sensor illuminates, and the analog output value is greater than 2048. When the N pole of the magnet faces the sensor detection area, the indicator light on the sensor illuminates, and the analog output value is less than 2048. (When no magnetic pole is detected, the analog value is between 2030-2060.)
| Detected South Pole Magnet | Detected North Pole Magnet | |
|---|---|---|
| Effect Display | ![]() |
![]() |
Was this article helpful?


