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