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


Python Arduino.delay方法代码示例

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


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

示例1: turn_left

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

示例2: reverse

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

示例3: forward

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

示例4: read_sensors

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import delay [as 别名]
def read_sensors():
    """
    Reads each of the Sharp sensors are returns a list of analog readings
    in order: front, right, left, rear
    """
    reading = []
    for i in [FrontBump, RightBump, LeftBump, RearBump]:
        reading.append(Arduino.analogRead(i))
        Arduino.delay(1)
    return reading
开发者ID:survinderpal,项目名称:RDuD2,代码行数:12,代码来源:sensorfuncs.py

示例5: rot_ccw

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

示例6: __fetchAddress

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import delay [as 别名]
    def __fetchAddress(self):
        ds_address = self.__ds.search()

        if ds_address == "1":
            return False

        self.__ds.reset()
        self.__ds.select(ds_address)
        self.__ds.write(0x44, 1)
        Arduino.delay(700)
        present = self.__ds.reset()
        self.__ds.select(ds_address)
        self.__ds.write(0xBE)
        return True
开发者ID:DarkSotM,项目名称:nanpy,代码行数:16,代码来源:mytemperaturelib.py

示例7: debug

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import delay [as 别名]
def debug():
    """
    If lock switch is in the locked position stop motors and give sensor feedback instead
    """
    stop()
    reading = read_sensors()
    Arduino.delay(5)
    if reading[0] > frontTrigger:
        print "Front bump detected!"
    elif reading[1] > sideTrigger:
        print "Right bump detected!"
    elif reading[2] > sideTrigger:
        print "Left bump detected!"
    elif reading[3] > rearTrigger:
        print "Rear bump detected!"
    else:
        print "Front:", reading[0], " | Right:", reading[1], " | Left:", reading[2], " | Rear:", reading[3]
        sleep(0.1)
开发者ID:russb78,项目名称:RDuD2,代码行数:20,代码来源:nanpy_avoider.py

示例8: get_pots

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import delay [as 别名]
def get_pots():
	"""
	Grab a reading from each of the pot pins and 
	send it to a tuple to be read by the colour mixer
	"""
	r = Arduino.analogRead(pot_r_Pin) / 4
	Arduino.delay(1)
	g = Arduino.analogRead(pot_g_Pin) / 4
	Arduino.delay(1)
	b = Arduino.analogRead(pot_b_Pin) / 4
	Arduino.delay(1)
	return r, g, b
开发者ID:russb78,项目名称:RGB-mixer,代码行数:14,代码来源:Colour_mix_project.py

示例9: rear_bump

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import delay [as 别名]
    if bump > sideTrigger:
        return True
    else:
        return False


def rear_bump():
    bump = Arduino.analogRead(RearBump)
    if bump > rearTrigger:
        return True
    else:
        return False


def read_sensors():
    """
    Reads each of the Sharp sensors are returns a list of analog readings
    in order: front, right, left, rear
    """
    reading = []
    for i in [FrontBump, RightBump, LeftBump, RearBump]:
        reading.append(Arduino.analogRead(i))
        Arduino.delay(1)
    return reading


while DEBUG:  # for sensor debugging purposes only
    reading = read_sensors()
    Arduino.delay(1)
    print "Front:", reading[0], " | Right:", reading[1], " | Left:", reading[2], " | Rear:", reading[3]
开发者ID:survinderpal,项目名称:RDuD2,代码行数:32,代码来源:sensorfuncs.py

示例10: diode

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import delay [as 别名]
#!/usr/bin/env python

# Author: Scott Ellis
# Basic Digital Read
# turns on and off a light emitting diode(LED) connected to digital  
# pin 13, when pressing a pushbutton attached to pin 5. 
# Dependencies: nanpy 0.7

from nanpy import Arduino

sensorButton = Arduino.digitalRead(5)
Arduino.pinMode(sensorButton, Arduino.INPUT)

ledPin = 13; 
Arduino.pinMode(ledPin, Arduino.OUTPUT)

while True:
    sensorButton = Arduino.digitalRead(5)
    print("sensor value: %d" % sensorButton)
    if (sensorButton == True):
        Arduino.digitalWrite(ledPin, Arduino.HIGH)
    else:
        Arduino.digitalWrite(ledPin, Arduino.LOW)
    Arduino.delay(100)
开发者ID:scottellis-,项目名称:candle_project,代码行数:26,代码来源:push_buttonConstantOn.py

示例11: get_b

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import delay [as 别名]
def get_b():
	b_val = Arduino.analogRead(pot_b_Pin) / 4
	Arduino.delay(1)
	return b_val
开发者ID:russb78,项目名称:RGB-mixer,代码行数:6,代码来源:RGB-mixer.py

示例12: get_g

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import delay [as 别名]
def get_g():
	g_val = Arduino.analogRead(pot_g_Pin) / 4
	Arduino.delay(1)
	return g_val
开发者ID:russb78,项目名称:RGB-mixer,代码行数:6,代码来源:RGB-mixer.py

示例13: get_r

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import delay [as 别名]
def get_r():
	r_val = Arduino.analogRead(pot_r_Pin) / 4
	Arduino.delay(1)
	return r_val
开发者ID:russb78,项目名称:RGB-mixer,代码行数:6,代码来源:RGB-mixer.py

示例14:

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import delay [as 别名]
__license__ = 'None'

from nanpy import Arduino as A
switchstate = 0

# SETUP:
A.pinMode(3, A.OUTPUT)
A.pinMode(4, A.OUTPUT)
A.pinMode(5, A.OUTPUT)

A.pinMode(2, A.INPUT)

# LOOP:
while True:
    switchState = A.digitalRead(2)
    if switchState == A.LOW:
        A.digitalWrite(3, A.HIGH) # turn the green LED on pin 3 on
        A.digitalWrite(4, A.LOW)  # turn the red LED on pin 4 off
        A.digitalWrite(5, A.LOW)  # turn the red LED on pin 5 off
    else:
        A.digitalWrite(3, A.LOW);  # turn the green LED on pin 3 off
        A.digitalWrite(4, A.LOW);  # turn the red LED on pin 4 off
        A.digitalWrite(5, A.HIGH); # turn the red LED on pin 5 on
        
        # wait for a quarter second before changing the light
        A.delay(250);
        A.digitalWrite(4, A.HIGH); #// turn the red LED on pin 4 on
        A.digitalWrite(5, A.LOW);  #// turn the red LED on pin 5 off
        
        # wait for a quarter second before changing the light
        A.delay(250);
开发者ID:mc7h,项目名称:arduino-starterkit-using-nanpy,代码行数:33,代码来源:spaceship_interface.py

示例15: print

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import delay [as 别名]
A.digitalWrite(4, A.LOW)

# LOOP
while True:
    sensorVal = A.analogRead(SENSOR_PIN_A0)
    voltage = (sensorVal / 1024.0) * 5.0
    temperature = (voltage - 0.5) * 100
    print("Sensor value: " + str(sensorVal) + ", Volts: " + str(voltage)  +", Degrees C: " + str(temperature) + ".")
    
    # if the current temperature is lower than the baseline turn off all LEDs
    if temperature < BASELINE_TEMP:
        A.digitalWrite(2, A.LOW)
        A.digitalWrite(3, A.LOW)
        A.digitalWrite(4, A.LOW)
    # if the temperature rises 2-4 degrees, turn an LED on 
    elif (temperature >= BASELINE_TEMP + 2 and temperature < BASELINE_TEMP + 4):
        A.digitalWrite(2, A.HIGH)
        A.digitalWrite(3, A.LOW)
        A.digitalWrite(4, A.LOW)
    # if the temperature rises 4-6 degrees, turn a second LED on  
    elif (temperature >= BASELINE_TEMP + 4 and temperature < BASELINE_TEMP + 6):
        A.digitalWrite(2, A.HIGH)
        A.digitalWrite(3, A.HIGH)
        A.digitalWrite(4, A.LOW)
    # if the temperature rises more than 6 degrees, turn all LEDs on
    elif (temperature >= BASELINE_TEMP + 6):
        A.digitalWrite(2, A.HIGH)
        A.digitalWrite(3, A.HIGH)
        A.digitalWrite(4, A.HIGH)
    A.delay(1)
开发者ID:mc7h,项目名称:arduino-starterkit-using-nanpy,代码行数:32,代码来源:love_o_meter.py


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