Python neopixel.NeoPixel() Examples
The following are 30
code examples of neopixel.NeoPixel().
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
neopixel
, 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: LEDStripConnector.py From Hector9000 with MIT License | 6 votes |
def __init__(self): self.PORT = board.D18 self.NUM = 15 self.NUMBASE = 5 self.pixels = neopixel.NeoPixel(self.PORT, self.NUM) self.cols = [ (255, 0, 0), (255, 63, 0), (255, 120, 0), (0, 255, 0), (0, 255, 255), (0, 0, 255), (255, 0, 255) ] self.col_neutral = (80, 80, 30) self.NUMCOLS = len(self.cols) self.mode = 1 self.ORDER = neopixel.GRB self.num_pixels = self.NUM self.pixels.fill(self.col_neutral) self.drinkcolor = (0,0,0)
Example #3
Source File: Simple_LED_Connector.py From Hector9000 with MIT License | 6 votes |
def __init__(self): self.PORT = board.D18 self.NUM = 15 self.NUMBASE = 5 self.pixels = neopixel.NeoPixel(self.PORT, self.NUM) self.cols = [ (255, 0, 0), (255, 63, 0), (255, 120, 0), (0, 255, 0), (0, 255, 255), (0, 0, 255), (255, 0, 255) ] self.col_neutral = (80, 80, 30) self.NUMCOLS = len(self.cols) self.mode = 1 self.ORDER = neopixel.GRB self.num_pixels = self.NUM self.pixels.fill(self.col_neutral) self.drinkcolor = (0,0,0) self.thr = threading.Thread(target=self.mode3, args=()) self.thr.start()
Example #4
Source File: hmeter.py From Micropython with MIT License | 6 votes |
def main(): # Wemos D1 Mini NeoPixel Shield is on pin 4 (D2) pin = machine.Pin(4, machine.Pin.OUT) # There is just 1 Neopixel LED on Shield n = neopixel.NeoPixel(pin, 1) # Wemos D1 Mini DHT Shield is on pin 2 (D4) d = dht.DHT22(machine.Pin(2)) while True: d.measure() h = d.humidity() print(h) if (h < 45): # RGB values n[0] = (127, 0, 0) else: n[0] = (0, 127, 0) # Write value to LEDs n.write() time.sleep(10)
Example #5
Source File: neo16x16.py From microbit-lib with MIT License | 6 votes |
def __init__(self, pin): self.np = NeoPixel(pin, 256) self.color = (0,0,8)
Example #6
Source File: led_strip.py From BerePi with BSD 2-Clause "Simplified" License | 5 votes |
def led_off(pin): if pin == 1: pixels = neopixel.NeoPixel(board.D12, 20) elif pin == 2: pixels = neopixel.NeoPixel(board.D18, 20) else: return False pixels.fill((0, 0, 0)) return True
Example #7
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)
Example #8
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 #9
Source File: neo16x16_img.py From mpy-lib with MIT License | 5 votes |
def __init__(self, pin): self.np = neopixel.NeoPixel(pin, 256)
Example #10
Source File: neo16x16.py From mpy-lib with MIT License | 5 votes |
def __init__(self, pin): self.np = neopixel.NeoPixel(pin, 256) self.color = (0,0,8)
Example #11
Source File: rgb_multi.py From ulnoiot-upy with MIT License | 5 votes |
def __init__(self, name, pin, num_of_leds=1, ignore_case=True, on_change=None, rgb_order=(1, 2, 3), report_change=False): self.rgb_order = rgb_order if num_of_leds <= 0: num_of_leds = 1 self.ws_leds = num_of_leds pin = neopixel.NeoPixel(pin, self.ws_leds) RGB_Base.__init__(self, name, pin, ignore_case=ignore_case, on_change=on_change, report_change=report_change)
Example #12
Source File: rgb_multi.py From ulnoiot-upy with MIT License | 5 votes |
def __init__(self, name, pin, num_of_leds=1, ignore_case=True, on_change=None, rgb_order=(1, 2, 3), report_change=False): self.rgb_order = rgb_order if num_of_leds <= 0: num_of_leds = 1 self.ws_leds = num_of_leds pin = neopixel.NeoPixel(pin, self.ws_leds) RGB_Base.__init__(self, name, pin, ignore_case=ignore_case, on_change=on_change, report_change=report_change)
Example #13
Source File: rgb_multi.py From ulnoiot-upy with MIT License | 5 votes |
def __init__(self, name, pin, num_of_leds=1, ignore_case=True, on_change=None, rgb_order=(1, 2, 3), report_change=False): self.rgb_order = rgb_order if num_of_leds <= 0: num_of_leds = 1 self.ws_leds = num_of_leds pin = neopixel.NeoPixel(pin, self.ws_leds) RGB_Base.__init__(self, name, pin, ignore_case=ignore_case, on_change=on_change, report_change=report_change)
Example #14
Source File: rgb_multi.py From ulnoiot-upy with MIT License | 5 votes |
def __init__(self, name, pin, num_of_leds=1, ignore_case=True, on_change=None, rgb_order=(1, 2, 3), report_change=False): self.rgb_order = rgb_order if num_of_leds <= 0: num_of_leds = 1 self.ws_leds = num_of_leds pin = neopixel.NeoPixel(pin, self.ws_leds) RGB_Base.__init__(self, name, pin, ignore_case=ignore_case, on_change=on_change, report_change=report_change)
Example #15
Source File: rgb_multi.py From ulnoiot-upy with MIT License | 5 votes |
def __init__(self, name, pin, num_of_leds=1, ignore_case=True, on_change=None, rgb_order=(1, 2, 3), report_change=False): self.rgb_order = rgb_order if num_of_leds <= 0: num_of_leds = 1 self.ws_leds = num_of_leds pin = neopixel.NeoPixel(pin, self.ws_leds) RGB_Base.__init__(self, name, pin, ignore_case=ignore_case, on_change=on_change, report_change=report_change)
Example #16
Source File: lamp.py From esp8266 with BSD 2-Clause "Simplified" License | 5 votes |
def set_np(self, pin, num_pixels) : self.np = neopixel.NeoPixel(machine.Pin(pin), num_pixels)
Example #17
Source File: lamp.py From esp8266 with BSD 2-Clause "Simplified" License | 5 votes |
def __init__(self, pin, num_pixels, colorspec, sleep_ms=100, num_transitions = 10, verbose=False) : core.task.TaskBase.__init__(self, sleep_ms, verbose=verbose) self.np = neopixel.NeoPixel(machine.Pin(pin), num_pixels) self.colorspec = colorspec self.prev_colorspec = None self.num_transitions = num_transitions self.transition_i = 0 self.initial_tick = None self.prev_rgb = None self.verbose = verbose
Example #18
Source File: main.py From sonoff-mqtt with BSD 2-Clause "Simplified" License | 5 votes |
def setup_neopixels(pin, count): global strip import neopixel strip = neopixel.NeoPixel(machine.Pin(pin), count) update_strip()
Example #19
Source File: circuit_playground_base.py From Adafruit_CircuitPython_CircuitPlayground with MIT License | 5 votes |
def pixels(self): """Sequence-like object representing the ten NeoPixels around the outside of the Circuit Playground. Each pixel is at a certain index in the sequence as labeled below. Colors can be RGB hex like 0x110000 for red where each two digits are a color (0xRRGGBB) or a tuple like (17, 0, 0) where (R, G, B). Set the global brightness using any number from 0 to 1 to represent a percentage, i.e. 0.3 sets global brightness to 30%. See `neopixel.NeoPixel` for more info. .. image :: ../docs/_static/neopixel_numbering.jpg :alt: NeoPixel order diagram Here is an example that sets the first pixel green and the ninth red. To use with the Circuit Playground Express or Bluefruit: .. code-block:: python from adafruit_circuitplayground import cp cp.pixels.brightness = 0.3 cp.pixels[0] = 0x00FF00 cp.pixels[9] = (255, 0, 0) """ return self._pixels
Example #20
Source File: neo16x16_img.py From microbit-lib with MIT License | 5 votes |
def __init__(self,pin): self.np=NeoPixel(pin,256)
Example #21
Source File: demo2.py From microbit-lib with MIT License | 5 votes |
def __init__(self, pin): self.np = NeoPixel(pin, 256) self.color = (0,0,8)
Example #22
Source File: rgb.py From kmk_firmware with GNU General Public License v3.0 | 5 votes |
def __init__(self, config, pixel_pin): try: import neopixel self.neopixel = neopixel.NeoPixel( pixel_pin, config['num_pixels'], pixel_order=config['rgb_order'], auto_write=False, ) if len(config['rgb_order']) == 4: self.rgbw = True self.num_pixels = const(config['num_pixels']) self.hue_step = const(config['hue_step']) self.sat_step = const(config['sat_step']) self.val_step = const(config['val_step']) self.hue = const(config['hue_default']) self.sat = const(config['sat_default']) self.val = const(config['val_default']) self.breathe_center = const(config['breathe_center']) self.knight_effect_length = const(config['knight_effect_length']) self.val_limit = const(config['val_limit']) self.animation_mode = config['animation_mode'] self.animation_speed = const(config['animation_speed']) if 'user_animation' in config: print(config['user_animation']) self.user_animation = config['user_animation'] except ImportError as e: print(e)
Example #23
Source File: neopixel_writer.py From thingflow-python with Apache License 2.0 | 5 votes |
def __init__(self, num_pixels=10, bytes_per_pixel=4, pinno=15): pin = Pin(pinno, Pin.OUT) self.np = NeoPixel(pin, num_pixels, bpp=bytes_per_pixel) self.bytes_per_pixel = bytes_per_pixel self.tuple_len = bytes_per_pixel+1
Example #24
Source File: bender_backlight.py From pRodriguezAssistant with GNU General Public License v3.0 | 5 votes |
def __init_pixels(self, leds): self.pin = leds[0] self.pixels = neopixel.NeoPixel(leds[0], leds[1], brightness=leds[2], auto_write=False, pixel_order=ORDER)
Example #25
Source File: adafruit_pyportal.py From Adafruit_CircuitPython_PyPortal with MIT License | 5 votes |
def neo_status(self, value): """The status NeoPixel. :param value: The color to change the NeoPixel. """ if self.neopix: self.neopix.fill(value)
Example #26
Source File: led_strip.py From BerePi with BSD 2-Clause "Simplified" License | 5 votes |
def led_color(pin, R=255,G=255,B=255): if pin == 1: pixels = neopixel.NeoPixel(board.D12, 20) elif pin == 2: pixels = neopixel.NeoPixel(board.D18, 20) else: return False pixels.fill((R, G, B)) return True
Example #27
Source File: circuit_playground_base.py From Adafruit_CircuitPython_CircuitPlayground with MIT License | 4 votes |
def __init__(self): self._a = digitalio.DigitalInOut(board.BUTTON_A) self._a.switch_to_input(pull=digitalio.Pull.DOWN) self._b = digitalio.DigitalInOut(board.BUTTON_B) self._b.switch_to_input(pull=digitalio.Pull.DOWN) self.gamepad = gamepad.GamePad(self._a, self._b) # Define switch: self._switch = digitalio.DigitalInOut(board.SLIDE_SWITCH) self._switch.switch_to_input(pull=digitalio.Pull.UP) # Define LEDs: self._led = digitalio.DigitalInOut(board.D13) self._led.switch_to_output() self._pixels = neopixel.NeoPixel(board.NEOPIXEL, 10) # Define sensors: self._temp = adafruit_thermistor.Thermistor( board.TEMPERATURE, 10000, 10000, 25, 3950 ) self._light = Photocell(board.LIGHT) # Define touch: # Initially, self._touches stores the pin used for a particular touch. When that touch is # used for the first time, the pin is replaced with the corresponding TouchIn object. # This saves a little RAM over using a separate read-only pin tuple. # For example, after `cp.touch_A2`, self._touches is equivalent to: # [None, board.A1, touchio.TouchIn(board.A2), board.A3, ...] # Slot 0 is not used (A0 is not allowed as a touch pin). self._touches = [ None, board.A1, board.A2, board.A3, board.A4, board.A5, board.A6, board.TX, ] self._touch_threshold_adjustment = 0 # Define acceleration: self._i2c = busio.I2C(board.ACCELEROMETER_SCL, board.ACCELEROMETER_SDA) self._int1 = digitalio.DigitalInOut(board.ACCELEROMETER_INTERRUPT) self._lis3dh = adafruit_lis3dh.LIS3DH_I2C( self._i2c, address=0x19, int1=self._int1 ) self._lis3dh.range = adafruit_lis3dh.RANGE_8_G # Define audio: self._speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) self._speaker_enable.switch_to_output(value=False) self._sample = None self._sine_wave = None self._sine_wave_sample = None # Initialise tap: self._detect_taps = 1 self.detect_taps = 1
Example #28
Source File: pyportal.py From Adafruit_CircuitPython_PyBadger with MIT License | 4 votes |
def __init__(self): super().__init__() # NeoPixels self._neopixels = neopixel.NeoPixel( board.NEOPIXEL, self._neopixel_count, brightness=1, pixel_order=neopixel.GRB ) self._light_sensor = analogio.AnalogIn(board.LIGHT)
Example #29
Source File: led_strip.py From BerePi with BSD 2-Clause "Simplified" License | 4 votes |
def led_on(pin): if pin == 1: pixels = neopixel.NeoPixel(board.D12, 20) elif pin == 2: pixels = neopixel.NeoPixel(board.D18, 20) else: print("wrong id") return False pixels.fill((255, 255, 255)) return True
Example #30
Source File: main.py From microhomie with MIT License | 4 votes |
def __init__(self, pin=5, leds=3): super().__init__( id="light", name="Ambient Light", type="WS2812B" ) self._brightness = 53 self.np = neopixel.NeoPixel(Pin(pin), leds) self.power_property = HomieNodeProperty( id="power", name="Light power", settable=True, retained=True, restore=True, datatype=BOOLEAN, default=FALSE, ) self.add_property(self.power_property, self.on_power_msg) self.color_property = HomieNodeProperty( id="color", name="RGB Color", settable=True, retained=True, restore=True, datatype=COLOR, default=DEFAULT, format=RGB, ) self.add_property(self.color_property, self.on_color_msg) self.brightness_property = HomieNodeProperty( id="brightness", name="LED brightness", settable=True, retained=True, restore=True, datatype=ENUM, format="1,2,3,4,5,6,7,8", default=4, ) self.add_property(self.brightness_property, self.on_brightness_msg)