The best kittens, technology, and video games blog in the world.

Friday, April 17, 2015

Adventures with Raspberry Pi: basic blinkenlights

Every adventure starts with hello world, and that one took forever.

Here's the setup:
Sunfounder GPIO extension board + breadboard make it so much easier - instead of wiring everything manually I just plug the whole damn thing, and it even has printed pin numbers on the board - Raspberry Pi decided to have insane randomly assigned pin numbers, and then every library for it uses its own different insane randomly assigned pin numbers - I remember back in the days when people numbered pins from 1 to 40 starting in one corner and going clockwise. What the hell happened?

I ran into a lot of annoying issues:
  • My old raspberry Pi (model B+, not 2 B) was not compatible with the kit, so I had to get new one
  • SD card I used for old Pi was of the big kind, so I had to take small one out of my phone instead
  • I needed to install confusingly named ruby1.9.1-dev apt package (which actually contains 1.9.3) before any gems would install.
  • And my voltmeter seems dead, it's probably just batteries, but it uses 9V batteries which I don't have spares for so I won't be able to check that until tomorrow.
  • Why do resistors have to use this ridiculous color coding system instead of just printing damn values as numbers? I get it that back in the 1950s printing numbers would be hard, but come on. Figuring out which resistor is which was pain, and I didn't have voltmeter to test them. (I never learned this damn color coding, as it was way easier to just check them with a meter).
  • It took a few tries to figure out which pin numbering system Pi Piper uses - apparently the same one as is printed on Sunfounder expansion board. That will make it a lot easier.
The first program is:


require "pi_piper"
pin4 = PiPiper::Pin.new(:pin => 4, :direction => :out)
pin17 = PiPiper::Pin.new(:pin => 17, :direction => :out)
loop { pin4.on; pin17.off; sleep 0.25; pin17.on; pin4.off; sleep 0.25 }

Can you guess what it does? No prizes.

It's not much, but with all hardware projects just getting basic hello world typically takes really long time and runs into a lot of annoying problems. Now that's behind me, I might be able to do some cooler stuff.

3D printer adventures and Raspberry Pi adventures will at some point join, but it will take a while.

No comments: