I spent part of the afternoon building this mini game controller: (video is bad, I would have needed three hands)
The “how” for most of this can be found here. I changed the Scratch code a bit, as I wanted an RGB LED, instead of three separate LEDs, but other than that, it’s pretty much the tutorial as is. Thank you Ben Miller!
Yesterday we had a little Coffee and Code with PyLadies Montreal. I was asked to bring a couple of Pis and “something to play with”. I brought mini breadboards and RGB leds.
After a brief explanation of the GPIO, the ladies started coding. We did get some result, but not the real thing. So before I forget how it works (cause I forget all the time now, sigh..) here’s the documentation on controlling an RGB led with the Pi’s GPIO.
First, the end result!
See? it does work!
Next, a schematic. I’m using a common anode RGB led.
Note that the anode is *not* the first leg, but rather the second leg. Grrr. Also, we’re not connecting the 5V to the anode as we did yesterday, but the Ground. The power will come from the pin when we set it to High. I *always* make that mistake, I don’t seem to be able to learn this for good. And that’s the main reason I didn’t become an electrical engineer. I suck at circuits.
So for future reference, here’s how a common anode RGB LED is supposed to be read.
Final score: 99%. Yeah, right! I got a 99% from an MIT class! Go me!
That said, the class served as a refresher of some Computer Science principles that I haven’t used in ages. Big-O Notation for one. I get it, I understand Big-O Notation, but I suck at it. I fail to properly identify which is which. I failed that concept when I was in university, and here I am 30 years later, still failing it. Sigh… Somehow, my brain blocks on this concept.
Apart from that, everything was review. It was mostly Computer Science, not even Python. I still think like a C programmer, and not a true Pythonista. And I know it. There were cases where I had to Google the proper Python way to do things, and not the C way. The class didn’t give any feedback on coding style, so I didn’t get the answers that I needed but getting access to Python code afterwards helped.