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


Python Arduino.analogWrite方法代码示例

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


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

示例1: stop

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogWrite [as 别名]
def stop():
    print "EXECUTING STOP"
    Arduino.analogWrite(SPEED_B_PIN, 0)
    Arduino.analogWrite(SPEED_A_PIN, 0)
    Arduino.analogWrite(LED_PIN_R, 200)
    Arduino.analogWrite(LED_PIN_G, 0)
    Arduino.analogWrite(LED_PIN_B, 0)
开发者ID:brianwu02,项目名称:rpi-arduino-car,代码行数:9,代码来源:runserver.py

示例2: close_pins

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogWrite [as 别名]
def close_pins():
    """
    Close all motor pins to quit cleanly upon end or exception
    """
    Arduino.analogWrite(speedA, Arduino.LOW)
    Arduino.analogWrite(speedB, Arduino.LOW)
    Arduino.digitalWrite(dirA, Arduino.LOW)
    Arduino.digitalWrite(dirB, Arduino.LOW)
开发者ID:survinderpal,项目名称:RDuD2,代码行数:10,代码来源:motorfuncs.py

示例3: go

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogWrite [as 别名]
def go(vel):
    """
    Start the motors and keep them running until told otherwise
    """
    Arduino.digitalWrite(dirA, Arduino.HIGH)
    Arduino.digitalWrite(dirB, Arduino.HIGH)
    Arduino.analogWrite(speedA, vel)
    Arduino.analogWrite(speedB, vel)
开发者ID:survinderpal,项目名称:RDuD2,代码行数:10,代码来源:motorfuncs.py

示例4: arduinoPinwriteoutInd

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogWrite [as 别名]
def arduinoPinwriteoutInd(outpin, PWM_Levelout):
    global targetpin
    targetpin = outpin
    global writeVAR
    writeVAR = PWM_Levelout
    if USE_FIRMATA:
        outpin.write(writeVAR / 255.0)
    elif USE_NANPY:
        Arduino.analogWrite(targetpin, writeVAR)
开发者ID:UncivillizedFrog,项目名称:fishtank,代码行数:11,代码来源:fishtank.py

示例5: forward

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogWrite [as 别名]
def forward(dist, vel):
    """
    Move forward for dist (time) at vel (motor speed)
    """
    Arduino.digitalWrite(dirA, Arduino.HIGH)
    Arduino.digitalWrite(dirB, Arduino.HIGH)
    Arduino.analogWrite(speedA, vel)
    Arduino.analogWrite(speedB, vel)
    Arduino.delay(dist)
开发者ID:survinderpal,项目名称:RDuD2,代码行数:11,代码来源:motorfuncs.py

示例6: turn_left

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogWrite [as 别名]
def turn_left(angle, vel):
    """
    Turns to the left according to angle (delay)
    """
    Arduino.digitalWrite(dirA, Arduino.HIGH)
    Arduino.digitalWrite(dirB, Arduino.LOW)
    Arduino.analogWrite(speedA, vel)
    Arduino.analogWrite(speedB, Arduino.LOW)
    Arduino.delay(angle)
开发者ID:survinderpal,项目名称:RDuD2,代码行数:11,代码来源:motorfuncs.py

示例7: reverse

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogWrite [as 别名]
def reverse(dist, vel):
    """
    Move backwards for dist (time) at vel (motor speed)
    """
    Arduino.digitalWrite(dirA, Arduino.LOW)
    Arduino.digitalWrite(dirB, Arduino.LOW)
    Arduino.analogWrite(speedA, vel)
    Arduino.analogWrite(speedB, vel)
    Arduino.delay(dist)
开发者ID:survinderpal,项目名称:RDuD2,代码行数:11,代码来源:motorfuncs.py

示例8: rot_ccw

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogWrite [as 别名]
def rot_ccw(angle, vel):
    """
    Spins to the left according to angle (delay),
    then stops the motors
    """
    Arduino.digitalWrite(dirA, Arduino.HIGH)
    Arduino.digitalWrite(dirB, Arduino.LOW)
    Arduino.analogWrite(speedA, vel)
    Arduino.analogWrite(speedB, vel)
    Arduino.delay(angle)
开发者ID:survinderpal,项目名称:RDuD2,代码行数:12,代码来源:motorfuncs.py

示例9: go_backward

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogWrite [as 别名]
def go_backward():
    print "executing go_backward"
    speed = 255
    direction = 1
    Arduino.digitalWrite(DIR_B_PIN, direction)
    Arduino.analogWrite(SPEED_B_PIN, speed)
    Arduino.digitalWrite(DIR_A_PIN, direction)
    Arduino.analogWrite(SPEED_A_PIN, speed)
    Arduino.analogWrite(LED_PIN_R, 155)
    Arduino.analogWrite(LED_PIN_G, 155)
    Arduino.analogWrite(LED_PIN_B, 155)
开发者ID:brianwu02,项目名称:rpi-arduino-car,代码行数:13,代码来源:runserver.py

示例10: go_right

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogWrite [as 别名]
def go_right():
    print "executing go_right"
    speed = 255
    direction_a = 1
    direction_b = 0
    Arduino.digitalWrite(DIR_B_PIN, direction_b)
    Arduino.analogWrite(SPEED_B_PIN, speed)
    Arduino.digitalWrite(DIR_A_PIN, direction_a)
    Arduino.analogWrite(SPEED_A_PIN, speed)
    Arduino.analogWrite(LED_PIN_R, 0)
    Arduino.analogWrite(LED_PIN_G, 0)
    Arduino.analogWrite(LED_PIN_B, 155)
开发者ID:brianwu02,项目名称:rpi-arduino-car,代码行数:14,代码来源:runserver.py

示例11: analogpin

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogWrite [as 别名]
def analogpin(pin_number):
    if request.method == 'GET':
        Arduino.pinMode(pin_number, Arduino.INPUT)
        data = {
            'value' : Arduino.analogRead(pin_number)
        }
        resp = Response(json.dumps(data), status=200, mimetype='application/json')
        return resp
    else:
        Arduino.pinMode(pin_number, Arduino.OUTPUT)
        Arduino.analogWrite(pin_number, request.json['value'])
        resp = Response("", status=200, mimetype='application/json')
        return resp
开发者ID:RobertJamesMason,项目名称:eggsamples,代码行数:15,代码来源:arduino.py

示例12: pwmLcdBacklight

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogWrite [as 别名]
    def pwmLcdBacklight(self, newState):

        step = 25

        if newState < self.unit['lcd'][0]['pwmState']:
            step = -step

        while self.unit['lcd'][0]['pwmState'] != newState:

            self.unit['lcd'][0]['pwmState'] += step
            Arduino.analogWrite(self.unit['lcd'][0]['backlightPin'],
                                self.unit['lcd'][0]['pwmState'])

        if (self.unit['lcd'][0]['pwmState'] > 128):

            self.unit['lcd'][0]['backlightState'] = True

        else:

            self.unit['lcd'][0]['backlightState'] = False
开发者ID:walln3r,项目名称:home,代码行数:22,代码来源:aio.py

示例13: colour_mixing

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogWrite [as 别名]
def colour_mixing():
	"""
	Call get_pots() and set 
	the colour pins accordingly
	"""
	r, g, b = get_pots()
	Arduino.analogWrite(redPin, r)
	Arduino.analogWrite(greenPin, g)
	Arduino.analogWrite(bluePin, b)
开发者ID:russb78,项目名称:RGB-mixer,代码行数:11,代码来源:Colour_mix_project.py

示例14: set_colour

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogWrite [as 别名]
def set_colour(r, g, b):
	"""
	simple colour fade for R, G, B.
	Colours can be set indivdually or mixed automatically
	by calling the 'get' functions below.
	"""
	Arduino.analogWrite(redPin, r)
	Arduino.analogWrite(greenPin, g)
	Arduino.analogWrite(bluePin, b)
开发者ID:russb78,项目名称:RGB-mixer,代码行数:11,代码来源:RGB-mixer.py

示例15: move

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import analogWrite [as 别名]
def move():
    movetype = request.json['type']
    duration = request.json['duration']

    if movetype == 'left':
        Arduino.digitalWrite(boardconfig.motor1_cp1, 0)
        Arduino.digitalWrite(boardconfig.motor1_cp2, 1)
        Arduino.analogWrite(boardconfig.motor1_ep, boardconfig.motor_speed)
    elif movetype == 'right':
        Arduino.digitalWrite(boardconfig.motor1_cp1, 1)
        Arduino.digitalWrite(boardconfig.motor1_cp2, 0)
        Arduino.analogWrite(boardconfig.motor1_ep, boardconfig.motor_speed)
    elif movetype == 'up':
        Arduino.digitalWrite(boardconfig.motor2_cp1, 0)
        Arduino.digitalWrite(boardconfig.motor2_cp2, 1)
        Arduino.analogWrite(boardconfig.motor2_ep, boardconfig.motor_speed)
    elif movetype == 'down':
        Arduino.digitalWrite(boardconfig.motor2_cp1, 1)
        Arduino.digitalWrite(boardconfig.motor2_cp2, 0)
        Arduino.analogWrite(boardconfig.motor2_ep, boardconfig.motor_speed)
    else:
        return jsonify({ 'error' : 'use type up, down, left or right' }), 400
    time.sleep(duration/1000)

    Arduino.analogWrite(boardconfig.motor2_ep, 0)
    Arduino.analogWrite(boardconfig.motor1_ep, 0)

    return jsonify({ 'status' : 'success' }), 200
开发者ID:atooma,项目名称:makerfaire-2014,代码行数:30,代码来源:chickenfoot.py


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