3. One-bit Sensors and Actuator

For sensors whose output is boolean and the required inputs only having VCC, GND and OUT/DATA, you can try to follow this document to read from it.

A typical One-bit Sensor looks like

../../../../../_images/one-bit-sensor.png

The general code to get sensor readings reads like.

import RPi.GPIO as GPIO
import time

#GPIO Mode (BOARD / BCM)
GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.cleanup()

DATA = 17  # BCM17 pin11

GPIO.setup(DATA, GPIO.IN)
time.sleep(0.1)

while True:
    if GPIO.input(DATA):
        print("Logic High")
    else:
        print("Logic Low")
    time.sleep(0.05)