當前位置: 首頁>>代碼示例>>Python>>正文


Python nanpy.Arduino類代碼示例

本文整理匯總了Python中nanpy.Arduino的典型用法代碼示例。如果您正苦於以下問題:Python Arduino類的具體用法?Python Arduino怎麽用?Python Arduino使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Arduino類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: stop

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,代碼行數:7,代碼來源:runserver.py

示例2: pirSense

    def pirSense(self):

        for key in self.unit['pir']:

            pin = self.unit['pir'][key]['pin']

            Arduino.pinMode(pin, Arduino.INPUT)
            self.unit['pir'][key].update(state=Arduino.digitalRead(pin))
開發者ID:walln3r,項目名稱:home,代碼行數:8,代碼來源:aio.py

示例3: forward

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,代碼行數:9,代碼來源:motorfuncs.py

示例4: lights

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,代碼行數:9,代碼來源:chickenfoot.py

示例5: arduinoPinwriteoutInd

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,代碼行數:9,代碼來源:fishtank.py

示例6: go_forward

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,代碼行數:9,代碼來源:runserver.py

示例7: turn_left

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,代碼行數:9,代碼來源:motorfuncs.py

示例8: reverse

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,代碼行數:9,代碼來源:motorfuncs.py

示例9: read_sensors

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,代碼行數:10,代碼來源:sensorfuncs.py

示例10: rot_ccw

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,代碼行數:10,代碼來源:motorfuncs.py

示例11: __fetchAddress

    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,代碼行數:14,代碼來源:mytemperaturelib.py

示例12: go

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,代碼行數:8,代碼來源:motorfuncs.py

示例13: close_pins

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,代碼行數:8,代碼來源:motorfuncs.py

示例14: get_pots

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,代碼行數:12,代碼來源:Colour_mix_project.py

示例15: main

def main():
    while True:
        try:
            locked = Arduino.digitalRead(lock)
            if locked == 0:
                debug()
            else:
                ### Actual Avoider coder starts below ###
                if not front_bump():
                    if not left_bump() and not right_bump():
                        print "No bump detected - on we go!"
                        go(200)
                        if left_bump() and not right_bump():
                            print "Left bump detected... Turning right"
                            rot_cw(100, 200)
                        elif right_bump() and not left_bump():
                            print "Right bump detected... Turning left"
                            rot_ccw(100, 200)
                        elif left_bump() and right_bump():
                            print "Both left & right bumps detected... Turning round!"
                            rot_cw(500, 200)
                else:
                    print "Front bump detected... Turning round!"
                    rot_cw(500, 200)
                # avoider code ends above
        except KeyboardInterrupt:
            close_pins()
            print "\nExiting"
            quit()
開發者ID:russb78,項目名稱:RDuD2,代碼行數:29,代碼來源:nanpy_avoider.py


注:本文中的nanpy.Arduino類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。