The Art of Debugging: A Kind of Book Review

Over the summer I read the book Debugging: The 9 Indispensable Rules For Finding the Most Elusive Software and Hardware Problems by David Agans.

The rules and processes he demonstrates in the book are thorough, solid, and extremely helpful when it comes to issues I’ve faced in my projects, programming, and understanding of how a computer works (even when I’m only reasoning through things in my head I’ve used these rules!).

These rules can not only be applied to computers, but attempting to figure any kind of problem in general.

Rule 1: Understand the System

Before you attempt troubleshooting, if you understand the system and how it’s supposed to work, reading the manual and figuring out the way all the pieces connect will aid you in the long run when you run into trouble. It’ll give you a good road map to follow if you get lost in bugs or issues.

Rule 2: Making It Fail

By far the best rule I’ve used. Stimulate the failure, don’t simulate it. As David Agans says, “Know that ‘that’ can happen.” By making something fail over and over again, in different ways, perhaps generating new errors, it gives you a better feel for what’s going on in the system.

Rule 3: Quit Thinking and LOOK.

Don’t keep hypothesizing, look at the internals about what’s actually going on. If you can literally “see” what’s going on, it’ll help you narrow down the possibilities.

Rule 4: Divide and Conquer

Find the range at which the bug is occurring, find the patterns, and allow that to help you narrow the search. As David Agans puts it, “If there’s goo, the pipe is upstream. If there’s no goo, the pipe is downstream.”

Rule 5: Change ONE Thing At A Time

Another one of my favorite rules. I used this tactic in building my mini computer when I had to figure out which signals were coming off of which GPIO pins to turn on the touchscreen. If you change one thing, it’ll aid in ruling out what’s not causing the issue and help you find what is.

Rule 6: Keep An Audit Trail

This one is incredibly important. Sometimes you can’t stay up until 3am attempting to fix a bug, and when you wake up in the morning or come back after school, you forgot what you tried the previous day. Simply keeping a file in the project folder of your computer or writing things down on sticky notes can boost your productivity because you’re able to remember the smaller details of the steps you took.

Rule 7: Check The Plug

If you got this far and still haven’t figured it out, go back to the basics. Is it plugged in the right way? Did you make sure to recompile it before running? Start at the beginning and make sure all your assumptions are correct.

Rule 8: Get A Fresh View

Getting an outside view on an issue or error can be a lifesaver. Don’t be too proud to ask for fresh insights or ask someone with more experience, they’ve all been where you have. “Bugs happen. Take pride in getting rid of them, not getting rid of them by yourself.” ~David Agans
When doing so, provide symptoms of what’s going on, don’t give someone else your theory of why it’s happening. Not only will you learn what’s going on better, but it’ll give better information to the person you’re asking to help you.

Rule 9: If You Didn’t Fix It, It Ain’t Fixed

A bug never decides to flit away on its own. If it randomly disappears, something else is likely wrong. Make sure it’s fixed by stimulating the failure, and if it isn’t fixed, head back to the drawing board.

Don’t forget to take brain breaks, debugging can be ugly and annoying.

I really enjoyed David Agan’s book, there’s much more content than anything I just shared. I highly recommend reading it, whether your a programmer, engineer, DIY-ist, even someone who just enjoys problem solving.

happy debugging!


Arkenpi – 3D Printed Case

Aaaand here she is!


Left to right, top to bottom: Keyboard bevel, Touchscreen bevel, case base, case top


Front closed ^


Back closed ^
Final product:


Credit to Gector for making the original design on fusion 360, and Jarin Alvarez for finishing the final design and printing it for me!

You can find the STL files on my github.

At the moment, the case is in my garage drying, I spray painted it! img_5188.jpg

The last thing I have to do once it’s dry is assemble it all together. Almost to the finish line!

ArkenpiTFT …The Redo

I was fiddling around with calibrating the PiTFT plus last night, and unfortunately, the Pi started booting to the HDMI instead of the TFT again. Needless to say, I was very grumpy.

Since I knew that the latest forms of Raspbian already supported the PiTFT and you don’t have to install the adafruit kernel: I said, “Screw this, I’m starting all over again.”

I wiped my SD card.

fdisk -l
fdisk /dev/sdx
d #delete partition
n #new partition
t #type
b #W95 FAT32
w #write
mkfs.vfat /dev/sdx1

I rewrote the latest Raspbian Stretch with the Desktop (2017-09-07).

dd bs=512k if=/home/thallia/2017-09-07-raspbian-jessie.img of=/dev/sdx

Once successfully booted into Raspbian Stretch on the HDMI output, I only cloned the Adafruit PiTFT Helper.

sudo apt-get update
git clone

Next I made the adafruit helper executable.

cd Adafruit-PiTFT-Helper
chmod +x
I ran the install.

sudo ./

In the middle of the install, it opened the options to configure the Pi for the TFT. It listed the types of screens in numbers from 1-5, in which I chose #4 (35r).
I chose “y”, and then magic! It rebooted onto the PiTFT.

It booted to the console, but changing the raspi-config settings to Desktop only booted the desktop to the HDMI.

I fixed this by following the answer on this forum.

sudo apt-get install xserver-xorg-video-fbdev

Next I made a file with the directory /usr/share/X11/xorg.conf.d/99-fbdev.conf, ( sudo nano /usr/share/X11/xorg.conf.d/99-fdbev.conf and pasted this stuff in there:
Section "Device"
Identifier "myfb"
Driver "fbdev"
Option "fbdev" "/dev/fb1"

After a reboot, my Pi was working a lot faster and it successfully booted the Desktop GUI onto the TFT.

I also changed my pi’s desktop photo to Marvel, because it looks freaking awesome.

4x4x4 Rainbow LED Cube (hardware)


  • 64 LEDs – 3mm
  • Resistors (you can calculate the amount of resistance you need, I used 200ohm)
  • a through-hole generic PCB board
  • Wooden board (not huge, just big enough to stick the LEDs in to solder the layers)
  • Hookup wire
  • Male-to-male jumper wires
  • Craft wire (I used 0.8mm)
  • Jumper wires
  • Elegoo Uno (I bought the Elegoo knockoff of an Arduino since I didn’t have a ton of money, it works exactly the same!)
  • A LOT of solder


  • Soldering station
  • Drill (with 3mm OR 1/8in drill bit)
  • Wire cutters and strippers
  • Round nose pliers
  • crocodile clips (very, very useful)


Step 1: Measure out equidistant holes in your wooden board. It’s really important that they’re as equal as you can get it, or else your LEDs are going to stand all wonky, and it’ll be hard to solder them all together.

I measured the holes about 1/2in apart.

Step 2: Drill the holes!
It helps to have an LED right next to you to make sure it’ll fit nicely in each hole.

Step 3: Solder the LED strips.
Take all the LEDs and bend the cathode (the short, negative lead) in such a way that it doesn’t touch the anode (the longer lead), and make sure when you fit them into the holes on your wooden board that the cathodes overlap each other so you can solder them together, like so:

Once you solder all the strips, lay them out in each set of holes, (with all the cathodes pointing the same way), and….

Step 4: Cut some craft wire and solder it across the LED strips to make it a square!

At this point I recommend using a 9V battery with a resistor on the positive (red) lead, and with the black lead touching the craft wire, go through and test all the LEDs to see if any burnt out or aren’t working. Trust me, it’ll save a LOT of time if you have to replace one now rather than later.

Step 5: Solder the layers!
Line the layers up on top of each other (one at a time), and remember that you’re *only soldering the leads pointing up*.

If you’re having a bit of trouble keeping the cube upright or the layers stable, the crocodile clips come in handy to steady the design.

The above picture was actually a mistake, I accidentally flipped the layer around the wrong way and had to desolder it because all the cathodes weren’t pointing the right way. (The cathodes being the shorter leads that you bent earlier) I wanted to show an example of the crocodile clips, though.

Once that’s completed, you can turn the cube right side up!

You can trim all the excess craft wire off. As for the cathodes sticking out on the sides, I cut them in a stepping-stone fashion like this tutorial said, which will make things easier once we hook the LEDs up to a PCB.

Step 6: Get the right PCB

I bought this PCB kit for…about $11, I think. It was a really good deal, these PCBs seem to work very nicely. They weren’t as big as they needed to be, though, so I hot glued two of them together.

This was probably the trickiest part of the whole project: getting 16 LED leads into tiny holes all at the same time. Round nose pliers were my best friend when I did it. Once you get them all in, solder all the joints at the bottom so all your hard work will stay in place!

Step 7: Put the resistors in.

Round nose pliers were super handy for this step as well. I chopped the leads of the resistors to be tinier than usual, then with some pliers I stuck them in the holes and soldered them in.

With the leftover resistor leads I used them as mini hookup wire to connect the resistors to the LEDs on the bottom of the board.

Step 8: Cut up some more craft wire and solder it to the negative stepping-stone leads, and wire them down to the PCB. img_5069img_5070
Step 9: Get some hookup wire, strip the ends, and pull them all towards the oval pads to connect to the jumper wire GPIO thingies.

I would recommend starting with the smaller hookup wires, I found it hard to solder around the bigger ones already in place without almost melting the insulation stuff. img_5077

Step 10: Solder the jumper wires to the board!img_5078
As you can see, I color coded the wires based on which resistor it was connected to. That way, I’ll have an easier time connecting the jumper wires to the GPIO pins on the Uno.

I still have to get some small wire or just use solder to connect the hookup wire to the actual resistors and GPIOs, so the signals will actually flow through the circuit. But otherwise, the big job is finished.

And that’s it! I followed this tutorial the whole time:

Next time, I’ll put up a post on the Uno, loading the code, and getting it all to run.


ArkenPi ~ the touchscreen (Adafruit PiTFT Plus 3.5”)

After hours of errors, outdated repos, and problem solving, I have finally gotten ArkenPi’s screen working!

Here’s how I did it:

First, install the most recent form of Raspbian. Turns out, the kernel is already updated to work with the Adafruit PiTFT 3.5″ PLUS, so you don’t have to download it from the outdated, unauthorized repositories (thank goodness).

Boot into your Raspbian OS and make sure you’re connected to a network, either way of ethernet, wifi adapter, or wirelessly (if you have a Pi 3). Go ahead and change your root password with passwd, then get into the raspberry pi configuration station.

Enter raspi-config into your terminal, and here’s what we’re gonna do:
1) Expand the filesystem
2) Change the default Pi account password
3) Enable Boot to Desktop (already signed in)
4) Enable Wait for Network at Boot
5) If you so wish, change your timezone
6) Set your hostname (the name of your pi)
7) Enable SSH (very handy if you run into errors)

Then select finish, reboot, and you’ll be set to go!

Once your Pi has rebooted, login as root sudo -s, and head back to raspi-config.
Head to Update, and update all the raspberry pi config settings. After that you’re free to exit.

Next, in a terminal, run apt-get update && apt-get -y upgrade.
Then you’re going to download some code from github.

Use wget -O /usr/bin/rpi-source to download it and put it somewhere.
We’re going to use chmod to make it executable like this:
chmod +x /usr/bin/rpi-source
then /usr/bin/rpi-source -q --tag-update.

After that, the guide I linked to in the previous post told me to wget some more driver code, but that code was outdated and removed from the repository. I didn’t really understand what the code was for, but I’m glad I looked.

The code was to initialize a GPIO pin as a power switch. That was a great idea and all, but I have another way of doing it hardware-wise which was much easier to figure out.

Next, we’re going to cd back to the Home directory and install the adafruit helper:
chmod +x ./adafruit-pitft-helper
and to run it, ./adafruit-pitft-helper -t 35r
Now, as shown above, the -t stands for type, and then you specify which PiTFT you have for your Raspberry Pi. Since mine was the 3.5″ Resistive touchscreen, 35r was my choice.

Finally, you can run shutdown -h now, set up the PiTFT on your RPi, and reboot to see it working!

Now, if you were like me, a few weird things happened when I started up. First, the Pi was still outputting the desktop onto my HDMI console, and only part of the boot process was actually showing up on the PiTFT.

In my config files, I made sure /etc/X11/xorg.conf.d/99-fbdev.conf had the line /dev/fb1 in it (wherever it was), because fb1 is the PiTFT output.

To fix this, I pressed Ctrl+Alt+*all the Fx keys*. Eventually one of the screens shifted to a login screen to my Pi, but logging in didn’t work. I would enter the right password, the screen would turn black with an underscore in the top left corner, then it would take me back to the login screen.

Turns out there’s a pesky little file you’ve got to delete:

sudo rm /home/pi/.XauthorityOnce I deleted that and rebooted, my PiTFT successfully displayed my desktop screen. Woohoo!!

Many times if I goofed and couldn’t access the desktop because I accidentally enabled boot-to-console, I would SSH into my raspberry pi. I must say I love SSH, I could do it all day. It’s such a cool thing to do. 😀

The only thing I’m struggling with now is actually getting the touchscreen calibrated the right way, which isn’t working.
I’m taking a break from the software side of this project to get oriented with how I’m going to put it all together in my 3D printed case, which is almost done. We’re getting to the exciting part of this now!