#!/usr/bin/env python3 import gpiozero import sys import time class Vector4Keyboard(gpiozero.DigitalOutputDevice): def __init__(self, pin): gpiozero.DigitalOutputDevice.__init__(self, pin, active_high=True, initial_value=True) def type(self, char): c = ord(char) self._bit(0) for bit in range(7): self._bit(c&1) c >>= 1 self._bit(0) self.on() time.sleep(71 / 1000) def _bit(self, bit): if bit: self.on() else: self.off() time.sleep(3.4 / 1000) kbd = Vector4Keyboard(2) print("Type:") while True: kbd.type(sys.stdin.read(1))