Read Switch status bitwise
Learn:
- Digital Input
- Switch
This program reads the digital input state.
ReadBit.py
import emant
m = emant.Emant300()
if m.Open("00:06:66:00:a1:f7"):
print m.HwId()
print m.ReadDigitalBit(3)
m.Close()
Code Explained
print m.ReadDigitalBit(3)
The ReadDigitalBit method returns a boolean value reflecting the switch status (True/False). As the switch is normally open and there is a pull up resistor on the digital input, a True will represent an unpressed switch.
