Use Factory to control Relay, Buzzer, or Electromagnet
masterThe Factory class provides a generic getGpioWrapper method to control various GPIO-based components.
Common identifiers include:
"Relay""Buzzer""Electromagnet""PIRMotion"(for mini PIR motion sensors)
Methods available on the returned wrapper include .on(), .off(), and for motion sensors, .has_motion().
from grove.factory import Factory
# Example: Relay
relay = Factory.getGpioWrapper("Relay", 16)
relay.on()
# Example: PIR Motion Sensor
pir = Factory.getGpioWrapper("PIRMotion", 5)
if pir.has_motion():
print("Motion detected")