当前位置: 首页>>代码示例>>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;未经允许,请勿转载。