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


Python Arduino.cmd_dcmotor_release方法代码示例

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


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

示例1: __init__

# 需要导入模块: from Arduino.Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino.Arduino import cmd_dcmotor_release [as 别名]
class DCMOTOR_ROTATION:
	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):
		self.pin1=9
		self.pin2=10
		self.obj_arduino.cmd_dcmotor_setup(1,3,1,self.pin1,self.pin2)
		self.obj_arduino.cmd_dcmotor_run(1,1,100)
		sleep(2)
		self.obj_arduino.cmd_dcmotor_release(1,1)
		
		
			

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

示例2: __init__

# 需要导入模块: from Arduino.Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino.Arduino import cmd_dcmotor_release [as 别名]
class SENSE:
    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()      #Locates the port 
        self.obj_arduino.open_serial(1,self.port,self.baudrate)
    def run(self):
        jlast=0
        k=0
        j=0
        self.pin1=9
        self.pin2=10
        self.intrp=5
        ilast=self.obj_arduino.cmd_digital_in(1,self.intrp)
        self.obj_arduino.cmd_dcmotor_setup(1,3,1,self.pin1,self.pin2)  # Initialize motor of the interrupt
        for s in range(5000):
            self.obj_arduino.cmd_dcmotor_run(1,1,100)    # Rotate the motor
            i=self.obj_arduino.cmd_digital_in(1,self.intrp)  # Read the signal of the receiver of IR sensor
            if i!=ilast:  # Check whether the motor is rotating
                if i=='1':  # Condition when the receiver receives the signal from transmitter
                    j=j+1
                sleep(0.01)
            ilast=i
            if j!=jlast:  
                print j
                if j%17==0 and j!=0:  # Condition for one complete rotation
                    k=k+1   # No of rotations
                    print 'number of rotations completed are',k
            jlast=j
        self.obj_arduino.cmd_dcmotor_release(1,1)

    def exit(self):
        self.obj_arduino.close_serial()
开发者ID:sbavlani,项目名称:IR-Interrupt,代码行数:39,代码来源:interrupt.py

示例3: __init__

# 需要导入模块: from Arduino.Arduino import Arduino [as 别名]
# 或者: from Arduino.Arduino.Arduino import cmd_dcmotor_release [as 别名]
class ENCODER:
    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()  #Locates the port 
        self.obj_arduino.open_serial(1,self.port,self.baudrate)

    def run(self):
        count=0;
        self.pwm1=9
        self.pwm2=10
        self.pin1=3
        self.pin2=4
        pinAlast=self.obj_arduino.cmd_digital_in(1,self.pin1)
        self.obj_arduino.cmd_dcmotor_setup(1,3,1,self.pwm1,self.pwm2)  # Initialize DC motor
        for i in range(2000):
            aVal=self.obj_arduino.cmd_digital_in(1,self.pin1)  
            if aVal!=pinAlast:                                   # To check whether encoder has rotated or not
                bVal=self.obj_arduino.cmd_digital_in(1,self.pin2)
                if bVal!=aVal:               # encoder has rotated in CW direction
                    count=count+1
                    print 'clockwise  ',count  
                    if count>0 and count<15:     # Speed control of DC motor
                        self.obj_arduino.cmd_dcmotor_run(1,1,40)
                        sleep(2)
                        self.obj_arduino.cmd_dcmotor_run(1,1,0)
                        sleep(1)
                    if count>=15 and count<30:
                        self.obj_arduino.cmd_dcmotor_run(1,1,80)
                        sleep(2)
                        self.obj_arduino.cmd_dcmotor_run(1,1,0)
                        sleep(1)
                    if count<0:
                        self.obj_arduino.cmd_dcmotor_run(1,1,120)
                        sleep(2)
                        self.obj_arduino.cmd_dcmotor_run(1,1,0)
                        sleep(1)
                else:                     # encoder has rotated in CCW direction
                    count=count-1
                    print 'anticlockwise  ',count
                    if count>-15 and count<0:    # Speed control of DC motor
                        self.obj_arduino.cmd_dcmotor_run(1,1,-40)
                        sleep(2)
                        self.obj_arduino.cmd_dcmotor_run(1,1,0)
                        sleep(1)
                    if count>-30 and count<=-15:
                        self.obj_arduino.cmd_dcmotor_run(1,1,-80)
                        sleep(2)
                        self.obj_arduino.cmd_dcmotor_run(1,1,0)
                        sleep(1)
                    if count>0:
                        self.obj_arduino.cmd_dcmotor_run(1,1,-120)
                        sleep(2)
                        self.obj_arduino.cmd_dcmotor_run(1,1,0)
                        sleep(1)
            pinAlast=aVal
        self.obj_arduino.cmd_dcmotor_release(1,1)
        
    def exit(self):
        self.obj_arduino.close_serial()
开发者ID:sbavlani,项目名称:Rotary-encoder,代码行数:67,代码来源:encoderdc.py


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