本文整理汇总了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))
示例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
示例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
示例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'
示例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()
示例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
示例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
示例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)
示例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)
示例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"
示例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
示例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)
示例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
示例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
示例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: