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


Python Motor.close方法代码示例

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


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

示例1: red_chanel

# 需要导入模块: from motor import Motor [as 别名]
# 或者: from motor.Motor import close [as 别名]
        self.bus_id = bus_id
        self.radio_id = radio_id
        self.bus = smbus.SMBus(self.bus_id)

    def red_chanel(self, ch_id):
        w = self.bus.read_word_data(self.radio_id, ch_id)
        return w

if __name__ == "__main__":

    m0 = Motor(0)
    m1 = Motor(1, -1)

    rc = Rcradio(2, 0x10)
    offset = 698

    try:
        while 1:
            speed = offset - rc.red_chanel(0)
            if abs(speed) < 3:
                speed = 0
            print(speed)
            m0.set_voltage(speed)
            m1.set_voltage(speed)
            time.sleep(0.1)

    except KeyboardInterrupt:
        m0.close()
        m1.close()
        pass
开发者ID:hajtohaj,项目名称:BBB_Balancer,代码行数:32,代码来源:test_rc.py

示例2: sleep

# 需要导入模块: from motor import Motor [as 别名]
# 或者: from motor.Motor import close [as 别名]
				ld.setstate(ld.GREEN)
				user = entry[USERNAME]	# if found > 1, this may log incorrect user. shouldnt happen.
				motor.power(ON)
                # Hardcoded
                # motor.open()
                
                turning = True
                while turning:
                    p0 = encoder.getpulses()
                    motor.rotate(num_steps=50, speed=0.2)
                    motor.steps += 50
                    p1 = encoder.getpulses()
                    if (p1 - p0) < # clk pulses equivalent to 50 steps
                        turning = False
                
				sleep(4)    # delay between release
                
                steps = motor.steps - 50    # always release less than we take
                motor.close(num_rotations=1, rotation_precision=steps)
				motor.power(OFF)
			else:
				ld.setstate(ld.RED)
				user = str()
				sleep(2)	# make illegal user wait
			db.loguser(addr, user)
			addr = None	# should be unneccesary
	
	# Not gonna get here, but it's good practice
	db.close()
	ld.setstate(ld.OFF)
开发者ID:explosionraptors,项目名称:CSEE-4920,代码行数:32,代码来源:main.py

示例3: getch

# 需要导入模块: from motor import Motor [as 别名]
# 或者: from motor.Motor import close [as 别名]
while c != 'q' and c != 'Q':
    t0 = time.time()
    r0 = m0.get_radians()
    c = getch()
    t1 = time.time()
    r1 = m0.get_radians()
    print("{0}, {1}".format(voltage, (r1 - r0)/(t1 - t0)))
    if ord(c) == 27:
        c = getch()
        if ord(c) == 91:
            c = getch()
            if ord(c) in key_map.keys():
                print(key_map[ord(c)])
                if key_map[ord(c)] == 'up':
                    voltage += voltage_step
                elif key_map[ord(c)] == 'down':
                    voltage -= voltage_step
    elif ord(c) == 32:
        pass
    else:
        print(ord(c))
    if voltage > 100:
        volate = 100
    if voltage < -100:
        voltage = -100
    m0.get_radians()
    m0.set_voltage(voltage)

m0.set_encoder(0)
m0.close()
开发者ID:hajtohaj,项目名称:BBB_Balancer,代码行数:32,代码来源:grab_input.py


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