Wednesday, December 3, 2014

All I want is to make that LED turn on!

I pulled out the ribbon cable and other pieces today to start playing with the GPIO pins. One would think that connecting a few wires isn't complicated. And it isn't. But I still somehow managed to get things wrong.
The first thing I've got wrong is that I don't have a multimeter. I started playing with this at around 8:45 PM, so I didn't have time to go out and buy one. I'll have to do that sometime in the next couple days.
But I went ahead and started connecting things anyway. My first task was to seat the ribbon cable connector (that came with the kit) into the breadboard. This took about 5 minutes to do even though it seems like it should take about 5 seconds. I spent a lot of time pushing on parts of it and thinking that I was going to break it. On the one hand, I've seen how some people have handled circuit boards and such, and so I know that they're at least somewhat robust. On the other hand, I'm not one of those people. I haven't handled these very much, so I don't really know what types of stresses they can take. Another issue I had was that it seemed to rock back and forth where the pins would go down on one side while coming up on the other side.
My next issue came with trying to connect the connector to the Pi with the ribbon cable. The connector has a notch on it to tell me which way the ribbon cable should go. But on the Pi side, it's just pins. That meant that I didn't really know which way to connect it. What's worse is that I can't see any of the internal circuitry to trace back and forth between the labeling and the physical locations of everything. I looked around on the internet for something that would help, but failed (even though I feel like I should have been able to succeed at that). So after a while, I just picked an orientation and connected it. (I've got a 50% chance, right?)
Someone who knows what's going on will instantly know whether this is right or wrong. But I'm not such a person. So I just kept going forward.
The next step was to wire up the LED. The instructions in both the Getting Started book and the Dummies book assume that you're connecting directly to the pins on the Pi (or that you've built your own ribbon connector). It was at this time that I discovered that there is a significant change in the configuration. The books were written for a Pi that has a 26 pin GPIO. The B+ has a 40 pin GPIO. I had no idea what this meant for the labeling of the pins. But after a bit of internet browsing, it seems that the first 26 pins are still pretty much the same, so that if I just stuck to that side for now I probably won't get myself into any trouble. It took a little bit of reasoning, but I eventually wired up an LED to GPIO25.
And yes, I'm aware that there's a pointless connection there. I fixed it later, but didn't bother taking another picture.
From here, it was time to boot up the Pi. I logged in and went through the various commands:
  • sudo su: This logs me in as the root so I have the access I need.
  • echo 25 > /sys/class/gpio/export: This is what creates the virtual files that controls the pin.
  • cd /sys/class/gpio/gpio25/: Change directories to the one that controls the pin.
  • echo out > direction: This tells the Pi I want to use the pin as an output.
  • echo 1 > value: This turns the pin on.

Unfortunately, the LED did not come on. I turned the LED around in case I had it backwards (LEDs are polarized, which means that they only work in one direction). And nothing happened.

The next thing I needed to do was turn the ribbon cable around on the Pi side and see if that's the problem. It was at that time that I discovered I had just spent an hour trying to get an LED to turn on, and decided to stop playing around with it and just type up my entry for the night. Just as a note to myself, after I typed this up, I turned the ribbon cable around so that next time I can just power it up and go from there. And upon staring at it for a moment, it seems like they probably would not have designed it so that the ribbon cable stretches across the entire motherboard. At least, that seems like it would have been a reasonable way to look at it.

No comments:

Post a Comment