本文整理汇总了Python中machine.Pin.init方法的典型用法代码示例。如果您正苦于以下问题:Python Pin.init方法的具体用法?Python Pin.init怎么用?Python Pin.init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类machine.Pin
的用法示例。
在下文中一共展示了Pin.init方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Buzz
# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import init [as 别名]
class Buzz(object):
def __init__(self,pin=6):
self.id=pins_remap_esp32[pin]
self.io=Pin(self.id)
self.io.value(1)
self.isOn=False
def on(self,freq=500):
if self.isOn is False:
self.pwm=PWM(self.io,freq,512)
self.isOn=True
def off(self):
if self.isOn:
self.pwm.deinit()
self.io.init(self.id,Pin.OUT)
self.io.value(1)
self.isOn=False
def freq(self,freq):
self.pwm.freq(freq)
示例2: lo_power
# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import init [as 别名]
def lo_power():
from machine import Pin, deepsleep
for pin in dir(Pin.board):
p = Pin(pin)
p.init(Pin.IN, pull=Pin.PULL_DOWN, alt=-1)
deepsleep()
示例3: Pin
# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import init [as 别名]
pin = Pin(pin_map[0], mode=Pin.OPEN_DRAIN, pull=Pin.PULL_UP)
pin = Pin(pin_map[0], mode=Pin.OUT, pull=Pin.PULL_DOWN)
pin = Pin(pin_map[0], mode=Pin.OUT, pull=None)
pin = Pin(pin_map[0], mode=Pin.OUT, pull=Pin.PULL_UP)
pin = Pin(pin_map[0], mode=Pin.OUT, pull=Pin.PULL_UP, drive=pin.LOW_POWER)
pin = Pin(pin_map[0], mode=Pin.OUT, pull=Pin.PULL_UP, drive=pin.MED_POWER)
pin = Pin(pin_map[0], mode=Pin.OUT, pull=Pin.PULL_UP, drive=pin.HIGH_POWER)
pin = Pin(pin_map[0], mode=Pin.OUT, drive=pin.LOW_POWER)
pin = Pin(pin_map[0], Pin.OUT, Pin.PULL_DOWN)
pin = Pin(pin_map[0], Pin.ALT, Pin.PULL_UP)
pin = Pin(pin_map[0], Pin.ALT_OPEN_DRAIN, Pin.PULL_UP)
test_pin_af() # try the entire af range on all pins
# test pin init and printing
pin = Pin(pin_map[0])
pin.init(mode=Pin.IN)
print(pin)
pin.init(Pin.IN, Pin.PULL_DOWN)
print(pin)
pin.init(mode=Pin.OUT, pull=Pin.PULL_UP, drive=pin.LOW_POWER)
print(pin)
pin.init(mode=Pin.OUT, pull=Pin.PULL_UP, drive=pin.HIGH_POWER)
print(pin)
# test value in OUT mode
pin = Pin(pin_map[0], mode=Pin.OUT)
pin.value(0)
pin.toggle() # test toggle
print(pin())
pin.toggle() # test toggle again
print(pin())
示例4: Pin
# 需要导入模块: from machine import Pin [as 别名]
# 或者: from machine.Pin import init [as 别名]
from machine import Pin
import pyb
import onewire
import onewireslave
import time
import os
import ubinascii
successled = pyb.LED(4)
warnled = pyb.LED(3)
shortpin = Pin('X12', mode=Pin.OUT)
shortpin.value(1)
toggleread = Pin('Y6', mode=Pin.OUT)
toggleread.value(0)
toggleread.init(Pin.IN)
if 1:
print("Write mode")
ows = onewireslave.OneWireSlave(Pin('Y5'), [0x01, 0x19, 0x76, 0x60, 0x09, 0x00, 0x00, 0x8e])
ows.waitForRequest(False)
else:
print("Read mode")
# create a OneWire bus on GPIO12
ow = onewire.OneWire(Pin('Y5'))
while True:
roms = ''
while not roms:
try:
roms = ow.scan()