{"id":19601328,"url":"https://github.com/sandyjmacdonald/bearables","last_synced_at":"2025-10-20T10:48:38.439Z","repository":{"id":84207249,"uuid":"111425856","full_name":"sandyjmacdonald/bearables","owner":"sandyjmacdonald","description":"Python library for the Pimoroni Bearables badges","archived":false,"fork":false,"pushed_at":"2018-01-16T16:50:11.000Z","size":12,"stargazers_count":9,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-27T17:39:45.228Z","etag":null,"topics":["leds","python","python-library","raspberry-pi"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sandyjmacdonald.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-11-20T15:10:40.000Z","updated_at":"2024-03-25T17:22:44.000Z","dependencies_parsed_at":"2023-05-23T23:30:17.475Z","dependency_job_id":null,"html_url":"https://github.com/sandyjmacdonald/bearables","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/sandyjmacdonald/bearables","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandyjmacdonald%2Fbearables","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandyjmacdonald%2Fbearables/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandyjmacdonald%2Fbearables/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandyjmacdonald%2Fbearables/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sandyjmacdonald","download_url":"https://codeload.github.com/sandyjmacdonald/bearables/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sandyjmacdonald%2Fbearables/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":280080684,"owners_count":26268353,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-20T02:00:06.978Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["leds","python","python-library","raspberry-pi"],"created_at":"2024-11-11T09:18:04.530Z","updated_at":"2025-10-20T10:48:38.433Z","avatar_url":"https://github.com/sandyjmacdonald.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Bearables\n\nThe Pimoroni [Bearables badges](https://shop.pimoroni.com/collections/bearables) include an I2C interface via the 5 programming pads on the reverse of the badges allowing basic control of the LED patterns, the individual LEDs, the button, and the ADC reading across the hooks when connected to a sensor, for example. This library exposes those functions.\n\n## Installation\n\nTo install the Bearables library, open a terminal window, and type the following:\n\n```\ngit clone https://github.com/sandyjmacdonald/bearables.git\ncd bearables/library\nsudo python3 setup.py install\n```\n\nNote that the installation requires the `smbus` library.\n\n## Interfacing\n\nThe 5 pads on the reverse of the badges, just below the Bearables logo, are used for programming the PIC microprocessor, but can also be used to power the badge and interface with it via I2C. If you're powering it through the 3V3 pin of your Pi or microprocessor, then make sure that you don't also have a battery in your badge.\n\nThe pads, from left to right, are as follows:\n\n* 9V reset\n* SDA\n* SCL\n* GND\n* 3V3\n\nThe easiest way to connect the badge to your Pi's GPIO is with a piece of right-angled male header soldered to the pads, and some female to female jumper jerky. Connect the SDA and SCL pins to your Pi's [SDA and SCL pins](https://pinout.xyz/pinout/i2c) and the 3V3 and GND to 3V3 power and ground respectively.\n\nThe badge should light up when connected. You can check that the I2C is being detected by typing `sudo i2cdetect -y 1`. It should show up with address `0x15`.\n\n## Examples\n\nThere are a number of examples in the [bearables/examples](examples) directory.\n\n## Functionality\n\n### LED patterns\n\nThe `set_pattern()` function allows you to select one of the 12 preset patterns on the badge, numbered from 0 to 11.\n\n```\nimport time\nfrom bearables import set_pattern\n\nwhile True:\n    for i in range(12):\n        set_pattern(i)\n        time.sleep(5)\n```\n\n### LED control\n\nThe `set_led()`, `set_all()`, `show()`, and `clear()` functions allow control of the LEDs, for programming your own patterns. The `show()` function must always be called after setting or clearing any LEDs, to display the changes on the badge's LEDs.\n\nHere's an example of how to cycle round the badge's LEDs at full brightness:\n\n```\nimport time\nfrom bearables import set_led, show, clear\n\nwhile True:\n    for i in range(12):\n        clear()\n        set_led(i, 1.0)\n        show()\n        time.sleep(0.05)\n```\n\nThe `set_led()` function takes two arguments, the LED number from `0` to `11`, and a brightness value from `0.0` to `1.0`. There's also a `set_all()` function that takes a single argument, the brightness value from `0.0` to `1.0`.\n\n### Button presses\n\nButton press events can be linked to functions using the `@on_press` decorator. The function to which the decorator is attached will fire every time the button is pressed. Here's an example that turns all of the LEDs on for two seconds when the button is pressed:\n\n```\nimport time\nfrom bearables import set_all, show, clear, on_press\n\n@on_press\ndef handle_press(self):\n    set_all(1.0)\n    show()\n    print(\"Button pressed!!\")\n    time.sleep(2)\n    clear()\n    show()\n\nwhile True:\n    pass\n```\n\n### ADC\n\nThe two sewable hooks on the back of the badges read raw ADC (analogue to digital converter) values (0-255) and can be used to read values from analog sensors like the Bearables sensors. You could also use them to read pins that are pulled high or low on attached microprocessors.\n\nHere's an example that reads the ADC value across the hooks:\n\n```\nimport time\nfrom bearables import read_adc\n\nwhile True:\n    print(read_adc())\n    time.sleep(0.2)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsandyjmacdonald%2Fbearables","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsandyjmacdonald%2Fbearables","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsandyjmacdonald%2Fbearables/lists"}