本文整理汇总了Python中Arduino.Arduino.Arduino.cmd_shift_out方法的典型用法代码示例。如果您正苦于以下问题:Python Arduino.cmd_shift_out方法的具体用法?Python Arduino.cmd_shift_out怎么用?Python Arduino.cmd_shift_out使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arduino.Arduino.Arduino
的用法示例。
在下文中一共展示了Arduino.cmd_shift_out方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Arduino.Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino.Arduino import cmd_shift_out [as 别名]
class SIPO_IC:
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)
def run(self):
pinstate=0
data=[0 for _ in range(0,8)] #an 8-elements list representing an 8 bit binary number
dataPin=11
clockPin=9
latchPin=10
inPin=5
for _ in range(0,50):
pinstate=self.obj_arduino.cmd_digital_in(1,inPin)
if pinstate=='1':
data[0]=1
#the msb becomes 1 when input is given
#high which is henceforth shifted
else:
data[0]=0
print data
self.obj_arduino.cmd_digital_out(1,latchPin,0)
self.obj_arduino.cmd_shift_out(dataPin,clockPin,'LSBFIRST',data)
self.obj_arduino.cmd_digital_out(1,latchPin,1)
sleep(0.5)
for k in range(0,7):
data[7-k]=data[6-k]
data[0]=0
#every element of the matrix is
#shifted one place to the right
#so effectively the 8 bit
#binary number is divided by 2
def exit(self):
self.obj_arduino.close_serial()
示例2: __init__
# 需要导入模块: from Arduino.Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino.Arduino import cmd_shift_out [as 别名]
class SIPO_IC:
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=11
clockPin=9
latchPin=10
#inPin=5
for x in range(0,256):
self.obj_arduino.cmd_digital_out(1,latchPin,0) #So that the data is stored and not passed on to the output LEDs
self.obj_arduino.cmd_shift_out(dataPin,clockPin,'MSBFIRST',x)
self.obj_arduino.cmd_digital_out(1,latchPin,1) #So that the stored data is now passed on to the output LEDs
#and the output is obtained
sleep(0.5)
def exit(self):
self.obj_arduino.close_serial()