• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python nanpy.Arduino类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了Arduino类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: send_updates_to_arduino

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)
开发者ID:StryKaizer,项目名称:Brew,代码行数:10,代码来源:tasks.py


示例17: debug

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,代码行数:18,代码来源:nanpy_avoider.py


示例18: pwmLcdBacklight

    def pwmLcdBacklight(self, newState):

        step = 25

        if newState < self.unit['lcd'][0]['pwmState']:
            step = -step

        while self.unit['lcd'][0]['pwmState'] != newState:

            self.unit['lcd'][0]['pwmState'] += step
            Arduino.analogWrite(self.unit['lcd'][0]['backlightPin'],
                                self.unit['lcd'][0]['pwmState'])

        if (self.unit['lcd'][0]['pwmState'] > 128):

            self.unit['lcd'][0]['backlightState'] = True

        else:

            self.unit['lcd'][0]['backlightState'] = False
开发者ID:walln3r,项目名称:home,代码行数:20,代码来源:aio.py


示例19: close_pins

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)
开发者ID:russb78,项目名称:RGB-mixer,代码行数:8,代码来源:Colour_mix_project.py


示例20: index

    def index(self,request):

        json = 0
        data = 0    
            
        if request.args.get('json', '') == "1":
            json = 1
            ser = Arduino()
            data = self.receiving(ser)
            sensorValue = Arduino.analogRead(analogPort)
            data= (sensorValue/1023.)*powervoltage*100
            print "data = ", data
        html = self.showDemoHTML(data,json)
        return html
开发者ID:ari-analytics,项目名称:tem_java,代码行数:14,代码来源:tempCore.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python nansat.Nansat类代码示例发布时间:2022-05-27
下一篇:
Python nanomsg.Socket类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap