{"id":16698821,"url":"https://github.com/prise6/hf-with-leds","last_synced_at":"2025-03-14T04:27:04.270Z","repository":{"id":111863595,"uuid":"120218607","full_name":"prise6/hf-with-leds","owner":"prise6","description":"Playing around with led strips / raspberry / mopidy / lightshowpi / spotify","archived":false,"fork":false,"pushed_at":"2018-02-05T08:30:27.000Z","size":142,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-20T23:26:27.648Z","etag":null,"topics":["led-strips","lightshowpi","mopidy","spotify"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/prise6.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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}},"created_at":"2018-02-04T20:04:42.000Z","updated_at":"2020-11-20T09:07:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"ca2ec5c0-85de-4fd1-a4a1-058b3c438207","html_url":"https://github.com/prise6/hf-with-leds","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prise6%2Fhf-with-leds","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prise6%2Fhf-with-leds/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prise6%2Fhf-with-leds/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/prise6%2Fhf-with-leds/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/prise6","download_url":"https://codeload.github.com/prise6/hf-with-leds/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243523199,"owners_count":20304555,"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","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":["led-strips","lightshowpi","mopidy","spotify"],"created_at":"2024-10-12T18:04:02.796Z","updated_at":"2025-03-14T04:27:04.244Z","avatar_url":"https://github.com/prise6.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n## Have Fun With Led Strip !\n\nWhat can we do with 4 meters of LEDs (32 leds/m) and raspberry pi ?\n\nMy steps:\n\n1- Connect and control leds with raspberry -\u003e Done\n\n2- Leds will react according to music playing on raspberry -\u003e Done\n\n3- Raspberry will also output the music -\u003e Done\n\n4- The music will come from Spotify stream -\u003e Done\n\n5- What about a spectrum analyzer ?\n\nI'm a real newbie in this field, here is my first approach.\n_Feel free to comment/create issue!_\n\n__This README is a draft__\n\n### Results (for now)\n\n__Images:__\n\n\n![Lights tower](www/photo1.jpg)\n\n![Circuit](www/photo2.jpg)\n\n__Videos:__\n\n[Small video](http://sendvid.com/tpxvd1zb)\n\n\n### Which existing tools can help me ?\n\n* WS2801 RGB LED : leds strip\n* Raspberry pi 3\n* [Mopidy](https://www.mopidy.com/) : music server, Spotify enabled\n* [BiblioPixel](https://github.com/ManiacalLabs/BiblioPixel) : Python library for programming light animation\n* [Lightshowpi](http://lightshowpi.org/) : a wonderful code to make your light dance to music with raspberry\n* [Raspbian](https://www.raspberrypi.org/downloads/raspbian/) : debian distribution for raspberry pi\n\n\n### What i needed\n\n* WS2801 RGB LED : [there](https://www.amazon.fr/gp/product/B06ZZZYHBQ)\n* Some wires \n* Solderless breadboard\n* Breadboard Power supply module\n* Power supply 5V\n\n### Assumption\n\n* Raspbian is installed\n* Direct / remote access to raspberry\n\n\n### Music server\n\nMopidy is very easy to install. See documentation on website. I also installed the [mopidy-spotify](https://github.com/mopidy/mopidy-spotify). Mopidy is running as a service and launch a webserver on 192.168.XX.XX where [iris](https://github.com/jaedb/iris) is installed.\n\nMy conf file is in `mopidy/mopidy.conf`. Notice Alsa chunk.\n\nI also  updates the service file because the service wasn't waiting for internet :\n\n```\ndo_start()\n{\n    if [ ! -d /var/cache/mopidy ]; then\n        mkdir -p /var/cache/mopidy\n        chown mopidy:audio /var/cache/mopidy\n    fi\n\n    ## my modification ...\n    sleep 30\n\n    start-stop-daemon --start --quiet --name $NAME --pidfile $PIDFILE \\\n        --startas $DAEMON --test \u003e /dev/null \\\n        || return 1\n    start-stop-daemon --start --quiet --name $NAME --pidfile $PIDFILE \\\n        --chuid $DAEMON_USER:$DAEMON_GROUP --background --make-pidfile \\\n        --startas $DAEMON -- --quiet --config $CONFIG_FILES \\\n        || return 2\n}\n```\n\n\n### Lightshowpi\n\nLightshow is really amazing. You can easily, without deep knowledges, create something nice with music and lights. \nTo install lighshowpi use official bitbucket repo.\n\nMy goal was to use the _audio-in_ method : the output of mopidy must be the input of lightshowpi AND raspberry outputs the sound.\n\nIn order to make this work, you need to create a loopback device with ALSA (next section).\n\nLightshowpi is writtent in python, i updates the `py/synchronized_lights.py` for my purposes :\n\n* make lightshowpi a service :\n\nadd shebang\n\n```\n#!/usr/bin/env python\n```\n\nneed to initialize variables:\n\n```\nos.environ[\"SYNCHRONIZED_LIGHTS_HOME\"] = \"/home/pi/lightshowpi\"\nHOME_DIR = os.getenv(\"SYNCHRONIZED_LIGHTS_HOME\")\n```\n\ncreate a file `init.d/lightshowpi` added to systemctl.\n\n* handle an error from audioop\n\nHappens when lighshowpi is \"recording\" and music is played after\n\n```\ntry:\n    audio_max = audioop.max(data, 2)\nexcept audioop.error:\n    audio_max = 0\n    continue\n```\n\n\n### ALSA\n\nWhy Alsa ? Always liked it, no more reason.\n\nOK, the issue was to make recordable the sound coming from alsa card. I found on the web two solutions:\n\nFirst of all, you need to enable the aloop module : `modprobe snd-aloop` and make it available on start.\n\n\n* 1)\n\nSee `alsa/asound.conf.card`.\nThis solution turns out to work with usb card, but not with raspberry alsa card. (_dmix_ seems not to work there)\n\n\n* 2)\n\nSee  `alsa/asound.conf`\nThis solution works with raspberry alsa card.\n\nIt creates a virtual recording card called _looprec_.\n\n\n__My Own Question:__\n\n* It seems that i needed to mix the sound (rate, buffer size, ...) of looprec. Is it necessary ?\n* Volume control acts on the volume lightshowpi receive in the second solution ?\n\n\n### Wires\n\nDocumentation found [here](https://tutorials-raspberrypi.com/how-to-control-a-raspberry-pi-ws2801-rgb-led-strip/)\n\n__My Own Question:__\n\n* For some reason i was not able to start my raspberry with 5V. So i supply the raspberry with 3.3V (micro usb), and the led strip with 5V. Do i still need to connect the raspberry ground pin to the ground of breaboard ? \n\n\n### Bibliopixel\n\nTODO\n\n\n### Random docs\n\nhttps://www.alsa-project.org/alsa-doc/alsa-lib/pcm_plugins.html\nhttps://raspberrypi.stackexchange.com/questions/57787/using-the-alsa-dmix-plugin-on-raspbian-jessie/61974\nhttps://www.raspberrypi.org/forums/viewtopic.php?t=64936\u0026p=481557\nhttps://bbs.archlinux.org/viewtopic.php?id=147852\nhttps://alsa.opensrc.org/Dsnoop\n\nhttps://docs.python.org/2/library/audioop.html \n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprise6%2Fhf-with-leds","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprise6%2Fhf-with-leds","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprise6%2Fhf-with-leds/lists"}