本文整理汇总了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)
示例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)
示例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)
示例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)
示例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)
示例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
示例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)
示例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)
示例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
示例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)
示例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
示例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)
示例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)
示例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
示例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