Playing with my PyBadge
Tags: python, pybadge, circuitpython, diversityintech
Published: 2020-06-23 14:30:23

##### 🗃 This is another [old post from Coding Grace](https://www.codinggrace.com/news/playing-with-my-pybadge-2019-11-17/) but a fun one that I want to share with the dev.to community. Enjoy! -- Vicky 😊

🥰 Finally got my hands on a [PyBadge](https://learn.adafruit.com/adafruit-pybadge/overview) (thanks, [@micktwomey](https://twitter.com/micktwomey)), been waiting impatiently ever since it was first announced, I think I saw it either via Adafruit's newsletter or their Youtube video (I recommend you subscribe to both).

{% twitter 1190635455575941121 %}

{% twitter 1190636983418261515 %}

It was a couple of weeks since my first play around with the **PyBadge** and I wanted to try out [PyBadger](https://learn.adafruit.com/pybadger-event-badge). So I followed the instructions, it was all grand until I wanted to get the neopixels to light up like the last time I played with it.

So I looked at the official PyBadge code example again: https://github.com/adafruit/Adafruit_Learning_System_Guides/tree/master/PyBadge_Conference_Badge

Hacked the code a bit and ran it, it says that `D8` is already in use (the **neopixels**). 😓🤔

Looked up **neopixels** docs on https://learn.adafruit.com/adafruit-neopixel-uberguide/python-circuitpython
Okay... code seems to be ok, why doesn't it work...🤔

I double-checked `D8` according to the [pinouts](https://learn.adafruit.com/adafruit-pybadge/pinouts) on Adadruit website, that's the **neopixels** I want to use alright.

Hmmm, ok, so I went to check out the **PyBadger** docs on https://circuitpython.readthedocs.io/projects/pybadger/en/latest/api.html
🔎 I noticed that there's a mention of **"pixels" - Sequence like object representing the NeoPixels on the board**. Double-hmm... this might be it. 🙌

The code in the [pybadge source code](https://github.com/adafruit/Adafruit_CircuitPython_PyBadger/blob/master/adafruit_pybadger.py) on github created **pixels** as a list variable, whereas **PyBadger**, it's already initiated it and it returns as pixels (as stated in the docs, but I had to see for myself)

Anyhoo, in the end, I modified the code in the end and it all worked. 🙌

The docs were a bit all over the place, and if I didn't know how to go digging with my detective hat on, I would have been a little stuck. That's the only thing I can complain about it, lots of docs, but it's a mess. I'm also terrible ending down rabbit holes and forgetting what I was doing in the first place. 😅

# End result
* Press `select` button, the neopixels light up and goes through a rainbow sequence
* Press `down` button, it dims the neopixels
* Press `up` button, it brightens the neopixels
* Press `start` button, it turns off the neopixels (also returns to original splash screen)
* Press `a` button, opens the business card screen (Dublin Maker logo and my emai address)
* Press `b` button, opens the QR code which links to [dublinmaker.ie](http://dublinmaker.ie).
And after years of hoarding lanyards from various conferences, I cobbled two lanyards and made it into one so I can hang my PyBadge. 🥰

{% twitter 1196024102068330498 %}

Final note: This was in preparation for my talk back on Nov 22nd 2019 where I was on the closing plenary panel at the [AWS Girls Tech Day](https://www.awsgirlstechday.com/event/f1cb36c1-3d7d-4e58-ab68-dc8564baee3f/summary) in Explorium Sports & Science Centre. 🙌

{% vimeo 382562855 %}