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


Python Arduino.digitalWrite方法代码示例

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


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

示例1: go

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import digitalWrite [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

示例2: close_pins

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import digitalWrite [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: reverse

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import digitalWrite [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

示例4: forward

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import digitalWrite [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

示例5: go_forward

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import digitalWrite [as 别名]
def go_forward():
    print "executing go_forward"
    speed = 255
    direction = 0
    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_G, 155)
开发者ID:brianwu02,项目名称:rpi-arduino-car,代码行数:11,代码来源:runserver.py

示例6: lights

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import digitalWrite [as 别名]
def lights():
    status = request.json['status']
    if status == 'on':
        Arduino.digitalWrite(boardconfig.lights_pin, 1)
    elif status == 'off':
        Arduino.digitalWrite(boardconfig.lights_pin, 0)
    else:
        return jsonify({ 'error' : 'use status on or off' }), 400
    return jsonify({ 'status' : 'success' }), 200
开发者ID:atooma,项目名称:makerfaire-2014,代码行数:11,代码来源:chickenfoot.py

示例7: turn_left

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import digitalWrite [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

示例8: rot_ccw

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import digitalWrite [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: taha

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import digitalWrite [as 别名]
def taha(N):
	Arduino.pinMode(13, Arduino.OUTPUT)
	while True:
		Arduino.digitalWrite(13, Arduino.HIGH)
		time.sleep(float(N))
		Arduino.digitalWrite(13, Arduino.LOW)
		time.sleep(float(N))
		lcd.setCursor(0, 1)
		lcd.printString(N)
		print N
开发者ID:pooyapooya,项目名称:rizpardazande,代码行数:12,代码来源:getNBlinkN2nanpyLCD.py

示例10: go_right

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import digitalWrite [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: digitalpin

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

示例12: send_updates_to_arduino

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import digitalWrite [as 别名]
def send_updates_to_arduino(batch):
    if batch.heat:
        Arduino.digitalWrite(ARDUINO_HEAT_PIN, Arduino.HIGH)
    else:
        Arduino.digitalWrite(ARDUINO_HEAT_PIN, Arduino.LOW)

    if batch.cool:
        Arduino.digitalWrite(ARDUINO_COOL_PIN, Arduino.HIGH)
    else:
        Arduino.digitalWrite(ARDUINO_COOL_PIN, Arduino.LOW)
开发者ID:StryKaizer,项目名称:Brew,代码行数:12,代码来源:tasks.py

示例13: close_pins

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import digitalWrite [as 别名]
def close_pins():
	"""
	Close pins to quit cleanly (doesn't work with a 'for
	loop' despite the pins happily initialising that way!)
	"""
	Arduino.digitalWrite(redPin,Arduino.LOW)
	Arduino.digitalWrite(greenPin,Arduino.LOW)
	Arduino.digitalWrite(bluePin,Arduino.LOW)
开发者ID:russb78,项目名称:RGB-mixer,代码行数:10,代码来源:Colour_mix_project.py

示例14: setBgColor

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import digitalWrite [as 别名]
def setBgColor():
    (triple, hexstr) = askcolor()
    if hexstr:
        print hexstr
        print (triple[0], " ", triple[1], " ", triple[2])
        a.analogWrite(RLED, triple[0])
        a.analogWrite(GLED, triple[1])
        a.analogWrite(BLED, triple[2])
        push.config(bg=hexstr)


print"Starting"
print"5 blinks"

a.digitalWrite(BLED,a.LOW)
a.digitalWrite(GLED,a.LOW)

for i in range(0,5):
    Arduino.digitalWrite(RLED, Arduino.HIGH)
    sleep(0.2)
    Arduino.digitalWrite(RLED, Arduino.LOW)
    sleep(0.2)

print"Changing brightness of LED"
bright = 128                           # Mid brightness
a.analogWrite(RLED, bright)
#a.digitalWrite(LED,a.HIGH)          # Turn on LED

for i in range(0,50):
    bright = bright + 8
开发者ID:MrRKernelPanic,项目名称:DioderLED,代码行数:32,代码来源:MRO_Nanpy2.py

示例15: move

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import digitalWrite [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.digitalWrite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。