Python machine.Pin.PULL_DOWN Examples
The following are 5
code examples of machine.Pin.PULL_DOWN().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
machine.Pin
, or try the search function
.
Example #1
Source File: controller_esp.py From SX127x_driver_for_MicroPython_on_ESP8266 with GNU General Public License v3.0 | 6 votes |
def get_spi(self): spi = None id = 1 if config_lora.IS_ESP8266: spi = SPI(id, baudrate = 10000000, polarity = 0, phase = 0) spi.init() if config_lora.IS_ESP32: try: if config_lora.SOFT_SPI: id = -1 spi = SPI(id, baudrate = 10000000, polarity = 0, phase = 0, bits = 8, firstbit = SPI.MSB, sck = Pin(self.PIN_ID_SCK, Pin.OUT, Pin.PULL_DOWN), mosi = Pin(self.PIN_ID_MOSI, Pin.OUT, Pin.PULL_UP), miso = Pin(self.PIN_ID_MISO, Pin.IN, Pin.PULL_UP)) spi.init() except Exception as e: print(e) if spi: spi.deinit() spi = None reset() # in case SPI is already in use, need to reset. return spi
Example #2
Source File: sht1x.py From upython-aq-monitor with MIT License | 6 votes |
def __init__(self, gnd, sck, data, vcc): self.gnd = gnd self.sck = sck self.data = data self.vcc = vcc self.gnd.mode(Pin.OUT) self.vcc.mode(Pin.OUT) self.sck.mode(Pin.OUT) self.data.mode(Pin.OPEN_DRAIN) self.gnd.pull(Pin.PULL_DOWN) self.vcc.pull(Pin.PULL_UP) self.sck.pull(Pin.PULL_DOWN) self.data.pull(None) self.sleep()
Example #3
Source File: digitalio.py From Adafruit_Blinka with MIT License | 6 votes |
def pull(self, pul): if self.direction is Direction.INPUT: self.__pull = pul if pul is Pull.UP: self._pin.init(mode=Pin.IN, pull=Pin.PULL_UP) elif pul is Pull.DOWN: if hasattr(Pin, "PULL_DOWN"): self._pin.init(mode=Pin.IN, pull=Pin.PULL_DOWN) else: raise NotImplementedError( "{} unsupported on {}".format(Pull.DOWN, board_id) ) elif pul is None: self._pin.init(mode=Pin.IN, pull=None) else: raise AttributeError("Not a Pull") else: raise AttributeError("Not an input")
Example #4
Source File: controller_esp.py From SX127x_driver_for_MicroPython_on_ESP8266 with GNU General Public License v3.0 | 5 votes |
def get_spi(self): spi = None id = 1 if config_lora.IS_ESP8266: spi = SPI(id, baudrate = 10000000, polarity = 0, phase = 0) spi.init() if config_lora.IS_ESP32: try: if config_lora.SOFT_SPI: id = -1 spi = SPI(id, baudrate = 10000000, polarity = 0, phase = 0, bits = 8, firstbit = SPI.MSB, sck = Pin(self.PIN_ID_SCK, Pin.OUT, Pin.PULL_DOWN), mosi = Pin(self.PIN_ID_MOSI, Pin.OUT, Pin.PULL_UP), miso = Pin(self.PIN_ID_MISO, Pin.IN, Pin.PULL_UP)) spi.init() except Exception as e: print(e) if spi: spi.deinit() spi = None reset() # in case SPI is already in use, need to reset. return spi
Example #5
Source File: ws2812.py From wipy-WS2812 with MIT License | 5 votes |
def __init__(self, ledNumber=1, brightness=100, dataPin='P22'): """ Params: * ledNumber = count of LEDs * brightness = light brightness (integer : 0 to 100%) * dataPin = pin to connect data channel (LoPy only) """ self.ledNumber = ledNumber self.brightness = brightness # Prepare SPI data buffer (8 bytes for each color) self.buf_length = self.ledNumber * 3 * 8 self.buf = bytearray(self.buf_length) # SPI init # Bus 0, 8MHz => 125 ns by bit, 8 clock cycle when bit transfert+2 clock cycle between each transfert # => 125*10=1.25 us required by WS2812 if uname().sysname == 'LoPy': self.spi = SPI(0, SPI.MASTER, baudrate=8000000, polarity=0, phase=1, pins=(None, dataPin, None)) # Enable pull down Pin(dataPin, mode=Pin.OUT, pull=Pin.PULL_DOWN) else: #WiPy self.spi = SPI(0, SPI.MASTER, baudrate=8000000, polarity=0, phase=1) # Enable pull down Pin('GP16', mode=Pin.ALT, pull=Pin.PULL_DOWN) # Turn LEDs off self.show([])