当前位置: 首页>>代码示例>>Python>>正文


Python Arduino.cmd_shift_in_n方法代码示例

本文整理汇总了Python中Arduino.Arduino.Arduino.cmd_shift_in_n方法的典型用法代码示例。如果您正苦于以下问题:Python Arduino.cmd_shift_in_n方法的具体用法?Python Arduino.cmd_shift_in_n怎么用?Python Arduino.cmd_shift_in_n使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Arduino.Arduino.Arduino的用法示例。


在下文中一共展示了Arduino.cmd_shift_in_n方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from Arduino.Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino.Arduino import cmd_shift_in_n [as 别名]
class PISO_IC_n:
    def __init__(self, baudrate):
        self.baudrate = baudrate
        self.setup()
        self.run()
        self.exit()

    def setup(self):

        self.obj_arduino = Arduino()
        self.port = self.obj_arduino.locateport()
        self.obj_arduino.open_serial(1, self.port, self.baudrate)

    # self.obj_icm=IC_methods(self.baudrate)

    def run(self):

        dataPin = 9
        clockPin = 10
        latchPin = 11

        ledPin = 5  # LED that shows serial output
        clockLed = 6  # LED that shows clock pulses

        p = int(raw_input("Enter no. of times parallel load is to be given: "))
        n = int(raw_input("Enter no. of bits: "))

        self.obj_arduino.cmd_digital_out(1, latchPin, 1)  # parallel load mode

        for _ in range(0, p):
            print ("Give input, Parallel load mode:")
            sleep(2)
            self.obj_arduino.cmd_digital_out(1, clockPin, 1)  # positive edge occurs
            # parallel load is stored
            print ("Inputs stored, Serial shift mode:")
            sleep(0.5)

            self.obj_arduino.cmd_digital_out(1, clockPin, 0)
            self.obj_arduino.cmd_digital_out(1, latchPin, 0)  # serial out mode

            self.obj_arduino.cmd_shift_in_n(dataPin, clockPin, ledPin, clockLed, n)

            self.obj_arduino.cmd_digital_out(1, latchPin, 1)
            self.obj_arduino.cmd_digital_out(1, ledPin, 0)

    def exit(self):
        self.obj_arduino.close_serial()
开发者ID:FOSSEE-Internship,项目名称:PyArduino,代码行数:49,代码来源:PISO_p_times_n_bits.py


注:本文中的Arduino.Arduino.Arduino.cmd_shift_in_n方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。