當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。