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


Python Arduino.pinMode方法代码示例

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


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

示例1: pirSense

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import pinMode [as 别名]
    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,代码行数:10,代码来源:aio.py

示例2: taha

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import pinMode [as 别名]
def taha(N):
	Arduino.pinMode(13, Arduino.OUTPUT)
	while True:
		Arduino.digitalWrite(13, Arduino.HIGH)
		time.sleep(float(N))
		Arduino.digitalWrite(13, Arduino.LOW)
		time.sleep(float(N))
		lcd.setCursor(0, 1)
		lcd.printString(N)
		print N
开发者ID:pooyapooya,项目名称:rizpardazande,代码行数:12,代码来源:getNBlinkN2nanpyLCD.py

示例3: digitalpin

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import pinMode [as 别名]
def digitalpin(pin_number):
    if request.method == 'GET':
        Arduino.pinMode(pin_number, Arduino.INPUT)
        data = {
            'value' : Arduino.digitalRead(pin_number)
        }
        resp = Response(json.dumps(data), status=200, mimetype='application/json')
        return resp
    else:
        Arduino.pinMode(pin_number, Arduino.OUTPUT)
        Arduino.digitalWrite(pin_number, request.json['value'])
        resp = Response("", status=200, mimetype='application/json')
        return resp
开发者ID:RobertJamesMason,项目名称:eggsamples,代码行数:15,代码来源:arduino.py

示例4: init_mashing

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import pinMode [as 别名]
def init_mashing(batch):

    # (Re)set defaults for batch
    set_batch_defaults(batch)
    set_variable('active_mashingprocess_batch_id', str(batch.id))

    # Initialize Arduino with Nanpy
    if not settings.ARDUINO_SIMULATION:
        sensor = DallasTemperature(ARDUINO_TEMPERATURE_PIN)
        addr = sensor.getAddress(ARDUINO_TEMPERATURE_PIN)
        Arduino.pinMode(ARDUINO_HEAT_PIN, Arduino.OUTPUT)
        Arduino.pinMode(ARDUINO_COOL_PIN, Arduino.OUTPUT)
        Arduino.pinMode(ARDUINO_STATUS_PIN, Arduino.OUTPUT)
        Arduino.digitalWrite(ARDUINO_HEAT_PIN, Arduino.LOW)
        Arduino.digitalWrite(ARDUINO_COOL_PIN, Arduino.LOW)
        Arduino.digitalWrite(ARDUINO_STATUS_PIN, Arduino.HIGH)
    else:
        # Set initial dummy temperature
        batch.temperature = 20  # Testing purpose only
        batch.save()
        batch = Batch.objects.get(id=batch.id)

    # Run Mashing proces
    while get_variable('active_mashingprocess_batch_id', 'None') == str(batch.id):
        # Measure data
        measured_data = {}
        if settings.ARDUINO_SIMULATION:
            measured_data['temp'] = get_dummy_temperature(batch)
        else:
            sensor.requestTemperatures()
            measured_data['temp'] = sensor.getTempC(addr)

        # Define actions depending on measured data
        batch = process_measured_data(batch.id, measured_data)

        # Send updates to arduino
        if not settings.ARDUINO_SIMULATION:
            send_updates_to_arduino(batch)

        # Send to logging department
        handle_logging(batch)

        # Delay
        sleep(DELAY_BETWEEN_MEASUREMENTS)

    Arduino.digitalWrite(ARDUINO_STATUS_PIN, Arduino.LOW)
    Arduino.digitalWrite(ARDUINO_COOL_PIN, Arduino.LOW)
    Arduino.digitalWrite(ARDUINO_HEAT_PIN, Arduino.LOW)

    return 'Mashing proces ended'
开发者ID:StryKaizer,项目名称:Brew,代码行数:52,代码来源:tasks.py

示例5: makeFig

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import pinMode [as 别名]
    #{
        #'x': [], 'y': [], 'type': 'scatter',
        #'stream': {
            #'token': plotly_user_config['plotly_streaming_tokens'][0],
            #axpoints': 200
        #}
    #}], filename='aRi Analytics Demonstration')

#print "View your streaming graph here: ", url

LED =10                        # LED on Arduino Pin 10 (with PWM)
# for measuring temperature
analogPort = 0
powervoltage = 5.
tempC = []
Arduino.pinMode(LED, Arduino.OUTPUT)
#Arduino.pinMode(analogPort, Arduino.INPUT)

# function makeFig()

def makeFig():
	plt.ylim(20,80)
	plt.title('Temperature Streaming')
	plt.grid(True)
#	plt.ylable('Temp C')
	plt.plot(tempC, 'ro-',label='Degree C')
	plt.legend(loc='upper left')
#	pyplot.show_bokeh(plt.gcf(), filename="mpltest.html")
#	plotting.session().dumpjson(file="mpltest.json")
        mpld3.show()
#	plt.show()		
开发者ID:ari-analytics,项目名称:myPython,代码行数:33,代码来源:tempc.py

示例6: import

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import pinMode [as 别名]
from flask import Flask, render_template, request
from nanpy import Arduino as A
from nanpy import (SPI, Wire, L3G, Servo)
import os
tmpl_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), '')

app = Flask(__name__, template_folder=tmpl_dir, static_url_path='')
import datetime

red = 8
green = 11
A.pinMode(red, A.OUTPUT)
A.pinMode(green, A.OUTPUT)

#####################
####### Gyro ########
#####################

L3G gyro
gyroSum = 0
gyroOffset = 0.0
Xval = 0

# gyro calibration variables
gyromin = -25000
gyromax = 25000

# gyro smoothing variables
i = 0
gyroaverage  = 0.
numReadings = 5
开发者ID:aaronrose87,项目名称:OttoPieneRobotControls,代码行数:33,代码来源:robotControlRouter.py

示例7: Kit

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import pinMode [as 别名]
"""
Spaceship Interface 
A Python/nanpy port of the SpaceshipInterface Sketch from the Arduino Starter Kit ( http://arduino.cc/starterKit)
"""
__version__ = '1.0'
__author__ = 'mc7h'
__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
开发者ID:mc7h,项目名称:arduino-starterkit-using-nanpy,代码行数:33,代码来源:spaceship_interface.py

示例8: startArduino

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import pinMode [as 别名]
def startArduino(outs):
    for i in range(len(outs)):
        Arduino.pinMode(outs[i], Arduino.OUTPUT)
        Arduino.digitalWrite(outs[i], 0)
开发者ID:F-M-A,项目名称:NanpyProjects,代码行数:6,代码来源:ejemplo.py

示例9: import

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

# Author: Andrea Stagi <[email protected]>
# Description: a lamp that turns a light on and off when you touch a piece of conductive material
# Dependencies: nanpy > 6.0

from nanpy import (Arduino, CapacitiveSensor)

capSensor = CapacitiveSensor(4,2)
threshold = 1000
ledPin = 12;

Arduino.pinMode(ledPin, Arduino.OUTPUT)

while True:
    sensorValue = capSensor.capacitiveSensor(30)
     
    print("Capacitive sensor value: %d" % sensorValue)

    if sensorValue > threshold:
        Arduino.digitalWrite(ledPin, Arduino.HIGH)
    else:
        Arduino.digitalWrite(ledPin, Arduino.LOW)
       
    Arduino.delay(10)
开发者ID:RobertJamesMason,项目名称:eggsamples,代码行数:27,代码来源:touchyfeelylamp.py

示例10: SerialManager

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import pinMode [as 别名]
from nanpy import Arduino
from nanpy import SerialManager
from time import sleep
from Tkinter import *
from tkColorChooser import askcolor

#serial_manager.connect('/dev/ttyS0')        # serial connection to Arduino
connection = SerialManager()
a = Arduino(connection=connection)
a.pinMode(5, a.OUTPUT)
a.pinMode(6, a.OUTPUT)
a.pinMode(3, a.OUTPUT)

RLED = 5                        # LED on Arduino Pin 10 (with PWM)
GLED = 3
BLED = 6

def setBgColor():
    (triple, hexstr) = askcolor()
    if hexstr:
        print hexstr
        print (triple[0], " ", triple[1], " ", triple[2])
        a.analogWrite(RLED, triple[0])
        a.analogWrite(GLED, triple[1])
        a.analogWrite(BLED, triple[2])
        push.config(bg=hexstr)


print"Starting"
print"5 blinks"
开发者ID:MrRKernelPanic,项目名称:DioderLED,代码行数:32,代码来源:MRO_Nanpy2.py

示例11:

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import pinMode [as 别名]
    pwmPin6 = board.get_pin("d:7:p")
    pwmPin7 = board.get_pin("d:8:p")
    pwmPin8 = board.get_pin("d:9:p")
else:
    boardPin = 13
    pwmPin1 = 2
    pwmPin2 = 3
    pwmPin3 = 4
    pwmPin4 = 5
    pwmPin5 = 6
    pwmPin6 = 7
    pwmPin7 = 8
    pwmPin8 = 9

if USE_NANPY:
    Arduino.pinMode(boardPin, Arduino.OUTPUT)
    Arduino.pinMode(pwmPin1, Arduino.OUTPUT)
    Arduino.pinMode(pwmPin2, Arduino.OUTPUT)
    Arduino.pinMode(pwmPin3, Arduino.OUTPUT)
    Arduino.pinMode(pwmPin4, Arduino.OUTPUT)
    Arduino.pinMode(pwmPin5, Arduino.OUTPUT)
    Arduino.pinMode(pwmPin6, Arduino.OUTPUT)
    Arduino.pinMode(pwmPin7, Arduino.OUTPUT)
    Arduino.pinMode(pwmPin8, Arduino.OUTPUT)
    # my version of firmata sets the pwm in the firmware
    set_timers()

targetpin = boardPin
PWM_Levelout = 0
outpin = 0
writeVAR = 0
开发者ID:pmacleod,项目名称:fishtank,代码行数:33,代码来源:fishtank.py

示例12: range

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

# Author: Andrea Stagi <[email protected]>
# Description: keeps your led blinking
# Dependencies: None

from nanpy import Arduino

Arduino.pinMode(13, Arduino.OUTPUT)

for i in range(10000):
    Arduino.digitalWrite(13, (i + 1) % 2)
    Arduino.delay(10)

开发者ID:OnyxShuriken,项目名称:nanpy,代码行数:15,代码来源:blink.py

示例13: getKey

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import pinMode [as 别名]
import os
from nanpy import Arduino, Lcd

Arduino.pinMode(14, input)

# Setup the LCD pins for the Keypad Shield
lcd = Lcd([8,9,7,6,5,4],[16,2])

max_trax = 6                                    

def getKey():                                    # Function to Translate the analogRead values from the Keys to a Command
   val = Arduino.analogRead(14)
   if val == 1023:
      return "NONE"
   elif val < 100:
      return "RIGHT"
   elif val < 150:
      return "UP"
   elif val < 330:
      return "DOWN"
   elif val < 510:
      return "LEFT"
   elif val < 750:
      return "SEL"
   else:
      return "KBD_FAULT"


def getTrack():
   L= [S.strip('\n') for S in os.popen('mpc').readlines()]    # Get the Track info from the stdout of the mpc command
   station = L[0][0:15]                                                         # Pick out the Station and Track info
开发者ID:nikhilpularru,项目名称:RaspRadio,代码行数:33,代码来源:radio.py

示例14: Stepper

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import pinMode [as 别名]
parser = optparse.OptionParser()
parser.add_option('-s', '--steps', type='int', action='store', dest='steps', help='motor steps', default=200)
options, args = parser.parse_args()

from nanpy import Stepper
from nanpy import Arduino

# Adjust for gravity
steps = options.steps if options.steps > 0 else options.steps + -100
print 'Motor Steps:', steps

# revsteps, pin1, pin2, speed
motor = Stepper(200, 12, 13, 50)

# Setup pins
Arduino.pinMode(3, Arduino.OUTPUT)
Arduino.pinMode(11, Arduino.OUTPUT)
Arduino.pinMode(9, Arduino.OUTPUT)
Arduino.pinMode(8, Arduino.OUTPUT)

# Turn off the brakes
Arduino.digitalWrite(9, Arduino.LOW)
Arduino.digitalWrite(8, Arduino.LOW)

# Turn on pulse width modulation
Arduino.digitalWrite(3, Arduino.HIGH)
Arduino.digitalWrite(11, Arduino.HIGH)

motor.step(steps)

# Turn off pulse width modulation
开发者ID:pschroen,项目名称:raisethepride,代码行数:33,代码来源:pflag.py

示例15: debug

# 需要导入模块: from nanpy import Arduino [as 别名]
# 或者: from nanpy.Arduino import pinMode [as 别名]
#!/usr/bin/env python
# Avoider sketch for Nanpy-controlled frindo bot
# Russell Barnes - 02 Oct 2013

from nanpy import Arduino
from nanpy import Servo
from time import sleep

from modules.motorfuncs import *
from modules.sensorfuncs import *
from modules.servofuncs import *
from modules.helperfuncs import *

lock = 5

Arduino.pinMode(lock, Arduino.INPUT)

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:
开发者ID:russb78,项目名称:RDuD2,代码行数:33,代码来源:nanpy_avoider.py


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