Python board.I2C Examples
The following are 6
code examples of board.I2C().
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
board
, or try the search function
.
Example #1
Source File: clue.py From Adafruit_CircuitPython_PyBadger with MIT License | 8 votes |
def __init__(self): super().__init__() i2c = board.I2C() if i2c is not None: self._accelerometer = adafruit_lsm6ds.LSM6DS33(i2c) # NeoPixels self._neopixels = neopixel.NeoPixel( board.NEOPIXEL, self._neopixel_count, brightness=1, pixel_order=neopixel.GRB ) self._buttons = GamePad( digitalio.DigitalInOut(board.BUTTON_A), digitalio.DigitalInOut(board.BUTTON_B), )
Example #2
Source File: adafruit_servokit.py From Adafruit_CircuitPython_ServoKit with MIT License | 6 votes |
def __init__( self, *, channels, i2c=None, address=0x40, reference_clock_speed=25000000 ): if channels not in [8, 16]: raise ValueError("servo_channels must be 8 or 16!") self._items = [None] * channels self._channels = channels if i2c is None: i2c = board.I2C() self._pca = PCA9685( i2c, address=address, reference_clock_speed=reference_clock_speed ) self._pca.frequency = 50 self._servo = _Servo(self) self._continuous_servo = _ContinuousServo(self)
Example #3
Source File: adafruit_motorkit.py From Adafruit_CircuitPython_MotorKit with MIT License | 6 votes |
def __init__(self, address=0x60, i2c=None, steppers_microsteps=16): self._motor1 = None self._motor2 = None self._motor3 = None self._motor4 = None self._stepper1 = None self._stepper2 = None if i2c is None: i2c = board.I2C() self._pca = PCA9685(i2c, address=address) self._pca.frequency = 1600 self._steppers_microsteps = steppers_microsteps # We can save memory usage (~300 bytes) by deduplicating the construction of the objects for # each motor. This saves both code size and the number of raw strings (the error message) # stored. The same technique is a net loss for stepper because there is less duplication.
Example #4
Source File: tftshield18.py From Adafruit_CircuitPython_seesaw with MIT License | 5 votes |
def __init__(self, i2c_bus=board.I2C(), addr=0x2E): super(TFTShield18, self).__init__(i2c_bus, addr) self.pin_mode(_TFTSHIELD_RESET_PIN, self.OUTPUT) self.pin_mode_bulk(self._button_mask, self.INPUT_PULLUP)
Example #5
Source File: pybadge.py From Adafruit_CircuitPython_PyBadger with MIT License | 5 votes |
def __init__(self): super().__init__() i2c = None if i2c is None: try: i2c = board.I2C() except RuntimeError: self._accelerometer = None if i2c is not None: int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT) try: self._accelerometer = adafruit_lis3dh.LIS3DH_I2C( i2c, address=0x19, int1=int1 ) except ValueError: self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1) # NeoPixels self._neopixels = neopixel.NeoPixel( board.NEOPIXEL, self._neopixel_count, brightness=1, pixel_order=neopixel.GRB ) self._buttons = GamePadShift( digitalio.DigitalInOut(board.BUTTON_CLOCK), digitalio.DigitalInOut(board.BUTTON_OUT), digitalio.DigitalInOut(board.BUTTON_LATCH), ) self._light_sensor = analogio.AnalogIn(board.A7)
Example #6
Source File: pygamer.py From Adafruit_CircuitPython_PyBadger with MIT License | 5 votes |
def __init__(self): super().__init__() i2c = board.I2C() int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT) try: self._accelerometer = adafruit_lis3dh.LIS3DH_I2C( i2c, address=0x19, int1=int1 ) except ValueError: self._accelerometer = adafruit_lis3dh.LIS3DH_I2C(i2c, int1=int1) # NeoPixels self._neopixels = neopixel.NeoPixel( board.NEOPIXEL, self._neopixel_count, brightness=1, pixel_order=neopixel.GRB ) self._buttons = GamePadShift( digitalio.DigitalInOut(board.BUTTON_CLOCK), digitalio.DigitalInOut(board.BUTTON_OUT), digitalio.DigitalInOut(board.BUTTON_LATCH), ) self._pygamer_joystick_x = analogio.AnalogIn(board.JOYSTICK_X) self._pygamer_joystick_y = analogio.AnalogIn(board.JOYSTICK_Y) self._light_sensor = analogio.AnalogIn(board.A7)