python类setup()的实例源码

PhotoBooth.py 文件源码 项目:raspi-photo-booth 作者: kriskbx 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def setup():
    if os.path.isdir(ImagePath) == False:
        os.mkdir(ImagePath, 0777)

    try:
        GPIO.cleanup()
    finally:
        pass

    GPIO.setmode(GPIO.BOARD)
    GPIO.setup(BeepPin, GPIO.OUT)
    GPIO.setup(LedPin, GPIO.OUT)
    GPIO.setup(ButtonPin, GPIO.IN, pull_up_down=GPIO.PUD_UP)

    ledOn()
    beepOn()
    time.sleep(0.1)
    ledOff()
    beepOff()

# Loop, wait for button press
FindDistance.py 文件源码 项目:RaspberryPi-Robot 作者: timestocome 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def __init__(self):

        gpio.setmode(gpio.BOARD)

        # set up  and init 
        self.trigger = 13
        self.echo = 11

        gpio.setup(self.trigger, gpio.OUT)
        gpio.setup(self.echo, gpio.IN)

        self.pulse_start = 0.
        self.pulse_end = 0.
        self.speed_of_sound = 343 * 100
        self.max_distance = 100
        self.min_distance = 1
MoveBlackRobot.py 文件源码 项目:RaspberryPi-Robot 作者: timestocome 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __init__(self):

        print('init robot gpio')
        # set up hardware
        gpio.setmode(gpio.BOARD)        # use pin numbers not gpio numbers


        # wheels ( 4 wheel motors )
        self.reverse_left = 38
        self.reverse_right = 35
        self.forward_left = 40
        self.forward_right = 37

        gpio.setup(self.reverse_left, gpio.OUT)  
        gpio.setup(self.forward_left, gpio.OUT)  
        gpio.setup(self.forward_right, gpio.OUT) 
        gpio.setup(self.reverse_right, gpio.OUT) 

        self.wheel_pulse = 0.2
        #self.actions = ['forward', 'reverse', 'turn_left', 'turn_right', 'hard_left', 'hard_right']
        self.actions = ['forward', 'reverse', 'hard_left', 'hard_right']
photobooth_main.py 文件源码 项目:photobooth 作者: eoghan-c 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def set_up_gpio(self):
        GPIO.setmode(GPIO.BCM)
        #GPIO.setup(camera_led_pin, GPIO.OUT, initial=False) # Set GPIO to output
        GPIO.setup(config.led_pin_select,GPIO.OUT) # The 'Select' button LED
        GPIO.setup(config.led_pin_left,GPIO.OUT) # The 'Left' button LED
        GPIO.setup(config.led_pin_right,GPIO.OUT) # The 'Right' button LED

        # Detect falling edge on all buttons
        GPIO.setup(config.button_pin_select, GPIO.IN, pull_up_down=GPIO.PUD_UP)
        GPIO.setup(config.button_pin_left, GPIO.IN, pull_up_down=GPIO.PUD_UP)
        GPIO.setup(config.button_pin_right, GPIO.IN, pull_up_down=GPIO.PUD_UP)
        GPIO.setup(config.button_pin_exit, GPIO.IN, pull_up_down=GPIO.PUD_UP)

        # Drumminhands found it necessary to switch off LEDs initially
        GPIO.output(config.led_pin_select, False)
        GPIO.output(config.led_pin_left, False)
        GPIO.output(config.led_pin_right, False)
RFID.py 文件源码 项目:nfcmusik 作者: ehansis 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def __init__(self, dev='/dev/spidev0.0', speed=1000000, pin_rst=22, pin_ce=0):
        self.pin_rst = pin_rst
        self.pin_ce = pin_ce

        SPI.openSPI(device=dev, speed=speed)
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(pin_rst, GPIO.OUT)
        GPIO.output(pin_rst, 1)
        if pin_ce != 0:
            GPIO.setup(pin_ce, GPIO.OUT)
            GPIO.output(pin_ce, 1)
        self.reset()
        self.dev_write(0x2A, 0x8D)
        self.dev_write(0x2B, 0x3E)
        self.dev_write(0x2D, 30)
        self.dev_write(0x2C, 0)
        self.dev_write(0x15, 0x40)
        self.dev_write(0x11, 0x3D)
        self.set_antenna(True)
step.py 文件源码 项目:pi-thrum 作者: arosspope 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __GPIOInit(self):
        """
        Initialises the GPIO pins for the pi
        (tested on the Pi3 Model B+)
        """
        # Set mode PIN numbering to BCM, and define GPIO pin functions
        GPIO.setmode(GPIO.BCM)

        # Setup Function for input Pins
        inputBNTs = (self.__soundBNTs + self.__stepBNTs)
        inputBNTs.append(self.__playBNT)
        inputBNTs.append(self.__recBNT)

        for b in inputBNTs:
            GPIO.setup(b, GPIO.IN, pull_up_down=GPIO.PUD_UP)

        # Func for ouput Pins
        GPIO.setup(self.__LED, GPIO.OUT)
common.py 文件源码 项目:waterflowers 作者: chaodalong 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def send_gpio_order(param):
    """
    GPIO????
    type in(GPIO.IN) out(GPIO.OUT)
    value 1 GPIO.HIGH 0 GPIO.LOW
    :param param:
    :return:
    """
    print param
    channel, type, value = param
    try:
        import RPi.GPIO as GPIO
    except RuntimeError:
        print("????")
    GPIO.setwarnings(False)
    GPIO.setmode(GPIO.BOARD)

    if type == 'in':
        GPIO.setup(channel, GPIO.IN)
        GPIO.input(channel, value)
    else:
        GPIO.setup(channel, GPIO.OUT)
        GPIO.output(channel, value)
gpio.py 文件源码 项目:mauzr 作者: eqrx 项目源码 文件源码 阅读 33 收藏 0 点赞 0 评论 0
def setup_output(self, name, pwm=False, initial=False):
        """ Set pin as output.

        :param name: Numer of the pin.
        :type name: int
        :param pwm: If value if PWM.
        :type pwm: bool
        :param initial: Initial value to set.
        :type initial: bool
        """

        self._pins[name] = {"name": name, "type": "out", "pwm": None}

        GPIO.setup(name, GPIO.OUT)
        if pwm:
            pwm = GPIO.PWM(name, 200)
            pwm.start(initial * 100.0)
            self._pins[name]["pwm"] = pwm
        else:
            self[name] = initial
I2C.py 文件源码 项目:BH1750 作者: ElJulio 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def init(self,bitrate,SDAPIN,SCLPIN):
        if(SDAPIN != SCLPIN):
            self.SCL = SCLPIN
            self.SDA = SDAPIN

        else:
            print "SDA = GPIO"+str(self.SDA)+"  SCL = GPIO"+str(self.SCL)

        #configer SCL as output
        GPIO.setmode(GPIO.BCM)
        GPIO.setwarnings(False)
        GPIO.setup(self.SCL, GPIO.OUT)
        GPIO.setup(self.SDA, GPIO.OUT)
        GPIO.output(self.SDA, GPIO.HIGH)
        GPIO.output(self.SCL, GPIO.HIGH)


        if bitrate == 100:
            self.int_clk = 0.0000025
        elif bitrate == 400:
            self.int_clk = 0.000000625
        elif bitrate == 1000:
            self.int_clk = 1
        elif bitrate == 3200:
            self.int_clk = 1
I2C.py 文件源码 项目:BH1750 作者: ElJulio 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def Start(self):
        #SCL
        #  ______
        #  |     |______
        #SDA
        #  ___
        #  |  |_________

        GPIO.setup(self.SDA, GPIO.OUT) #cnfigure SDA as output

        GPIO.output(self.SDA, GPIO.HIGH)
        GPIO.output(self.SCL, GPIO.HIGH)
        self.tick(1)
        GPIO.output(self.SDA, GPIO.LOW)
        self.tick(1)
        GPIO.output(self.SCL, GPIO.LOW)
        self.tick(2)
I2C.py 文件源码 项目:BH1750 作者: ElJulio 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def ReadAck(self):
        GPIO.setup(self.SDA, GPIO.IN)
        readbuffer =0
        for i in range(8):
            GPIO.output(self.SCL, GPIO.HIGH)
            self.tick(2)
            readbuffer |= (GPIO.input(self.SDA)<< 7) >> i
            GPIO.output(self.SCL, GPIO.LOW)
            self.tick(2)

        GPIO.setup(self.SDA, GPIO.OUT)
        GPIO.output(self.SDA, GPIO.LOW)
        GPIO.output(self.SCL, GPIO.HIGH)
        self.tick(2)
        GPIO.output(self.SCL, GPIO.LOW)
        GPIO.output(self.SDA, GPIO.LOW)
        self.tick(2)
        return readbuffer
I2C.py 文件源码 项目:BH1750 作者: ElJulio 项目源码 文件源码 阅读 30 收藏 0 点赞 0 评论 0
def ReadNack(self):
        GPIO.setup(self.SDA, GPIO.IN)
        readbuffer =0
        for i in range(8):
            GPIO.output(self.SCL, GPIO.HIGH)
            self.tick(2)
            readbuffer |= (GPIO.input(self.SDA)<< 7) >> i
            GPIO.output(self.SCL, GPIO.LOW)
            self.tick(2)

        GPIO.setup(self.SDA, GPIO.OUT)
        GPIO.output(self.SDA, GPIO.HIGH)
        GPIO.output(self.SCL, GPIO.HIGH)
        self.tick(2)
        GPIO.output(self.SCL, GPIO.LOW)
        GPIO.output(self.SDA, GPIO.LOW)
        self.tick(2)
        return readbuffer
relay.py 文件源码 项目:BoilerPlate 作者: wyaron 项目源码 文件源码 阅读 25 收藏 0 点赞 0 评论 0
def test_relay():
   """Test relay on and off cycle"""

   # check if the output is high
   print 'current control output is: ', is_output_high(), ' (should be off)'

   # start the relay
   start_relay()

   print 'current control output is: ', is_output_high(), ' (should be on)'

   # setup a timer to stop the relay after 5 seconds
   t = Timer(5, stop_relay)
   t.start()

   # wait for the timer to finish
   t.join()
DoorBellTest.py 文件源码 项目:SmartDoorControl 作者: xiaokaizh 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def signalDoorBell():
    global doorBell
    global belli
    global bellSum
    global previousDoorBell
    global GPIO_doorBell
    global GPIO_bell
    if belli != 15:
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(GPIO_doorBell, GPIO.IN)
        bellSum = bellSum + GPIO.input(GPIO_doorBell)
        belli += 1
    else:
        belli = 0
        if bellSum >= 15:
            doorBell = 1
        else:
            doorBell = 0
        if doorBell != previousDoorBell:
            previousDoorBell = doorBell
            DeviceControl.doorBell(doorBell)
            print("Dang qian doorBell %s" % doorBell)
        bellSum = 0
ShockTest.py 文件源码 项目:SmartDoorControl 作者: xiaokaizh 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def signalshock():
        global shocki
        global shockSum
        global shock
        global GPIO_shock
        if shocki != 5:
            GPIO.setmode(GPIO.BOARD)
            GPIO.setup(GPIO_shock, GPIO.IN)
            shockSum = shockSum+GPIO.input(GPIO_shock)
            shocki += 1
        else:
            shocki = 0
            if shockSum >=2:
                shock = 1
            else:
                shock = 0
            global previousShock
            if shock != previousShock:
                previousShock = shock
                print("Dang qian shock %s" % shock)
            shockSum = 0
SignalCollect.py 文件源码 项目:SmartDoorControl 作者: xiaokaizh 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def signaliR():
        global iRi
        global iRSum
        global iR
        global GPIO_iR
        if iRi != 5:
            GPIO.setmode(GPIO.BOARD)
            GPIO.setup(GPIO_iR, GPIO.IN)
            iRSum = iRSum+GPIO.input(GPIO_iR)
            iRi += 1
        else:
            iRi = 0
            if iRSum >= 2:
                iR = 1
            else:
                iR = 0
            global previousIR
            if iR != previousIR:
                previousIR = iR
                print("Dang qian IR %s"%iR)
            iRSum = 0
            IRStateMachine.stateJudge(iR)


# ??????
drivers.py 文件源码 项目:burro 作者: yconst 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def __init__(self, channel, invert=False):
        from navio import adafruit_pwm_servo_driver as pwm
        from navio import util
        import RPi.GPIO as GPIO
        util.check_apm()

        #Navio+ requires the GPIO line 27 to be set to low 
        #before the PCA9685 is accesed 
        GPIO.setwarnings(False)
        GPIO.setmode(GPIO.BCM)
        GPIO.setup(27, GPIO.OUT)
        GPIO.output(27,GPIO.LOW)

        #GPIO.cleanup()
        self.frequency = 60
        self.channel = channel
        self.invert = invert
        self.pwm = pwm.PWM()
        self.pwm.setPWMFreq(self.frequency)
ringer.py 文件源码 项目:red-phone 作者: mixmasteru 项目源码 文件源码 阅读 32 收藏 0 点赞 0 评论 0
def __init__(self, ready):
        Thread.__init__(self)
        self.ready = ready
        self.picked_up = False
        self.on = True
        self._ringer1 = 11
        self._ringer2 = 13
        self._button = 7

        GPIO.setmode(GPIO.BOARD)
        GPIO.setwarnings(False)
        GPIO.setup(self._ringer1, GPIO.OUT)
        GPIO.output(self._ringer1, GPIO.LOW)
        GPIO.setup(self._ringer2, GPIO.OUT)
        GPIO.output(self._ringer2, GPIO.LOW)
        GPIO.setup(self._button, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)

        self._last_state = 0
        self._last_ts = time.time()
        self._last_check = time.time()
        self._ring = 1
        self.max_ring_cnt = 2
charlieplexing-6-on-3.py 文件源码 项目:52-Weeks-of-Pi 作者: grantwinney 项目源码 文件源码 阅读 35 收藏 0 点赞 0 评论 0
def main():
    try:
        while True:
            for led in LEDS:
                for idx, pin in enumerate(led):
                    if pin == O:
                        GPIO.setup(PINS[idx], GPIO.IN)
                    else:
                        GPIO.setup(PINS[idx], GPIO.OUT)
                        GPIO.output(PINS[idx], pin)
                time.sleep(.1)

    except KeyboardInterrupt:
        pass

    finally:
        GPIO.cleanup()
sample_gpio_function.py 文件源码 项目:raspberry-gpio-emulator 作者: nosix 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def main():
    import RPi.GPIO as GPIO

    try:
        print('UNKNOWN:%d' % GPIO.UNKNOWN)
        print('SERIAL:%d' % GPIO.SERIAL)
        print('SPI:%d' % GPIO.SPI)
        print('I2C:%d' % GPIO.I2C)
        print('HARD_PWM:%d' % GPIO.HARD_PWM)

        GPIO.setmode(GPIO.BOARD)

        GPIO.setup(3, GPIO.OUT)

        for pin in range(1, 41):
            try:
                print('%02d: %d' % (pin, GPIO.gpio_function(pin)))
            except ValueError as ex:
                print(ex)
    finally:
        GPIO.cleanup()
sample_pwm.py 文件源码 项目:raspberry-gpio-emulator 作者: nosix 项目源码 文件源码 阅读 21 收藏 0 点赞 0 评论 0
def main():
    import RPi.GPIO as GPIO
    import time

    GPIO.setmode(GPIO.BCM)
    GPIO.setup(12, GPIO.OUT)
    p = GPIO.PWM(12, 50)
    try:
        p.start(0)
        for dc in range(0, 101, 5):
            p.ChangeDutyCycle(dc)
            time.sleep(0.1)
        for dc in range(100, -1, -5):
            p.ChangeDutyCycle(dc)
            time.sleep(0.1)
    finally:
        p.stop()
        GPIO.cleanup()
sample_custom_ui_launcher.py 文件源码 项目:raspberry-gpio-emulator 作者: nosix 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def main():
    import RPi.GPIO as GPIO
    import time

    try:
        GPIO.setmode(GPIO.BCM)

        GPIO.setwarnings(False)

        GPIO.setup(18, GPIO.OUT)
        GPIO.setup(27, GPIO.IN)

        while True:
            time.sleep(1)
    finally:
        GPIO.cleanup()
sample_plugin_launcher.py 文件源码 项目:raspberry-gpio-emulator 作者: nosix 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def main():
    import RPi.GPIO as GPIO
    import time

    try:
        GPIO.setmode(GPIO.BCM)

        GPIO.setwarnings(False)

        GPIO.setup(18, GPIO.OUT)
        GPIO.setup(27, GPIO.IN)

        while True:
            time.sleep(1)
    finally:
        GPIO.cleanup()
rccar.py 文件源码 项目:rl-rc-car 作者: harvitronix 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __init__(self, left_p=13, right_p=15, forward_p=12, backward_p=11,
                 apply_time=0.3, wait_time=0):
        self.left_p = left_p
        self.right_p = right_p
        self.forward_p = forward_p
        self.backward_p = backward_p
        self.apply_time = apply_time
        self.wait_time = wait_time

        print("Setting up GPIO pins.")
        GPIO.setmode(GPIO.BOARD)
        GPIO.setup(self.backward_p, GPIO.OUT)  # Backwards.
        GPIO.setup(self.forward_p, GPIO.OUT)  # Forwards.
        GPIO.setup(self.left_p, GPIO.OUT)  # Left.
        GPIO.setup(self.right_p, GPIO.OUT)  # Right.

        # Reset in case they're still on from before.
        GPIO.output(self.backward_p, 0)
        GPIO.output(self.forward_p, 0)
        GPIO.output(self.left_p, 0)
        GPIO.output(self.right_p, 0)
GartenwasserGPIO.py 文件源码 项目:Gartenwasser 作者: bgewehr 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def on_message(mosq, obj, msg):
    """
    Handle incoming messages
    """
    if msg.topic == MONITOR_REFRESH:
        refresh()
        return

    topicparts = msg.topic.split("/")
    pin = int(topicparts[len(topicparts) - 1])
    try:
        value = int(float(msg.payload))
    except ValueError:
        value = 0

    if pin not in GPIO_OUTPUT_PINS:
        GPIO.setup(pin, GPIO.OUT, initial=GPIO.HIGH)
        GPIO_OUTPUT_PINS.append(pin)
    if topicparts[2] == 'in':
        if value == 1:
            GPIO.output(pin, GPIO.LOW)
        else:
            GPIO.output(pin, GPIO.HIGH)

# End of MQTT callbacks
mcp3008.py 文件源码 项目:pimaa 作者: outboxafrica 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def __init__(self, data):
        GPIO.setmode(GPIO.BCM)
        GPIO.setwarnings(False)
        self.SPIMOSI = 23
        self.SPIMISO = 24
        self.SPICLK = 18
        self.SPICS = 25
        if "mosiPin" in data:
            self.SPIMOSI = data["mosiPin"]
        if "misoPin" in data:
            self.SPIMISO = data["misoPin"]
        if "clkPin" in data:
            self.SPICLK = data["clkPin"]
        if "csPin" in data:
            self.SPICS = data["csPin"] 
        GPIO.setup(self.SPIMOSI, GPIO.OUT)
        GPIO.setup(self.SPIMISO, GPIO.IN)
        GPIO.setup(self.SPICLK, GPIO.OUT)
        GPIO.setup(self.SPICS, GPIO.OUT)
        if MCP3008.sharedClass == None:
            MCP3008.sharedClass = self

    #read SPI data from MCP3008 chip, 8 possible adc's (0 thru 7)
sound_record.py 文件源码 项目:SmartSlam 作者: Oneiroe 项目源码 文件源码 阅读 24 收藏 0 点赞 0 评论 0
def wait_pir(DEBUG=False):
    """ Loops till PIR doesn't detect something"""
    # setting GPIO PINs
    with open(SETTINGS) as file:
        settings = json.load(file)

        logging.info('Setting GPIO PINS')
        GPIO.setmode(GPIO.BOARD)

        GPIO.setup(settings['pir_pin_board'], GPIO.IN)

    #####################
    # PIR cycle

    logging.info('Starting PIR waiting cycle...')

    if DEBUG:
        while input('insert 1 to start...') != '1':
            time.sleep(0.1)
    else:
        while GPIO.input(settings['pir_pin_board']) is not 1:
            time.sleep(0.1)

    logging.info('PIR detection')
    return
RpiUtils.py 文件源码 项目:kalliope 作者: kalliope-project 项目源码 文件源码 阅读 27 收藏 0 点赞 0 评论 0
def init_gpio(self, rpi_settings):
        """
        Initialize GPIO pin to a default value. Leds are off by default
        Mute button is set as an input
        :param rpi_settings: RpiSettings object
        """
        # All led are off by default
        if self.rpi_settings.pin_led_muted:
            GPIO.setup(rpi_settings.pin_led_muted, GPIO.OUT, initial=GPIO.LOW)
        if self.rpi_settings.pin_led_started:
            GPIO.setup(rpi_settings.pin_led_started, GPIO.OUT, initial=GPIO.LOW)
        if self.rpi_settings.pin_led_listening:
            GPIO.setup(rpi_settings.pin_led_listening, GPIO.OUT, initial=GPIO.LOW)
        if self.rpi_settings.pin_led_talking:
            GPIO.setup(rpi_settings.pin_led_talking, GPIO.OUT, initial=GPIO.LOW)

        # MUTE button
        if self.rpi_settings.pin_mute_button:
            GPIO.setup(rpi_settings.pin_mute_button, GPIO.IN, pull_up_down=GPIO.PUD_UP)
            GPIO.add_event_detect(rpi_settings.pin_mute_button, GPIO.FALLING,
                                  callback=self.switch_kalliope_mute_led,
                                  bouncetime=500)
pyRPiRTC.py 文件源码 项目:rpi.rtc 作者: sourceperl 项目源码 文件源码 阅读 28 收藏 0 点赞 0 评论 0
def __init__(self, clk_pin=11, data_pin=13, ce_pin=15):
        # init GPIO
        # no warnings
        GPIO.setwarnings(False)
        # use safer pin number (avoid GPIO renumber on each Pi release)
        GPIO.setmode(GPIO.BOARD)
        # set GPIO pins
        self._clk_pin = clk_pin
        self._data_pin = data_pin
        self._ce_pin = ce_pin
        # CLK and CE (sometime call RST) pin are always output
        GPIO.setup(self._clk_pin, GPIO.OUT, initial=GPIO.LOW)
        GPIO.setup(self._ce_pin, GPIO.OUT, initial=GPIO.LOW)
        # turn off WP (write protect)
        self._start_tx()
        self._w_byte(0x8e)
        self._w_byte(0x00)
        self._end_tx()
        # charge mode is disabled
        self._start_tx()
        self._w_byte(0x90)
        self._w_byte(0x00)
        self._end_tx()
pyRPiRTC.py 文件源码 项目:rpi.rtc 作者: sourceperl 项目源码 文件源码 阅读 23 收藏 0 点赞 0 评论 0
def _r_byte(self):
        """
        Read byte from the chip.

        :return: byte value
        :rtype: int
        """
        # data pin is now input (pull-down resistor embedded in chip)
        GPIO.setup(self._data_pin, GPIO.IN)
        # clock the byte from chip
        byte = 0
        for i in range(8):
            # make a high pulse on CLK pin
            GPIO.output(self._clk_pin, GPIO.HIGH)
            time.sleep(self.CLK_DELAY)
            GPIO.output(self._clk_pin, GPIO.LOW)
            time.sleep(self.CLK_DELAY)
            # chip out data on clk falling edge: store current bit into byte
            bit = GPIO.input(self._data_pin)
            byte |= ((2 ** i) * bit)
        # return byte value
        return byte


问题


面经


文章

微信
公众号

扫码关注公众号