Limit Switch
Overview
Press-type switch digital input module. Pressing outputs a high level; otherwise, it outputs a low level.
Technical Specifications
Operating voltage: VCC 3.3V -5V
Module dimensions: 24*48mm
Mounting: 2 plastic building block compatible through-holes
Data type: Triggered–1 Not triggered–0
Pin Definition
Pin |
Definition |
|---|---|
GND |
Ground |
VCC |
Power |
DO |
Digital output |
NC |
Not connected |
Example Code
When the limit switch is triggered, the mPython Board RGB LED lights up.
from mpython import *
p0 = MPythonPin(0, PinMode.IN)
import time
def boolean_P0():
return p0.read_digital() == 1
while True:
if boolean_P0():
rgb.fill((int(255), int(0), int(0)))
rgb.write()
time.sleep_ms(1)
time.sleep(1)
else:
rgb.fill( (0, 0, 0) )
rgb.write()
time.sleep_ms(1)