Reading List

The most recent articles from a list of feeds I subscribe to.

Relay

I opened up Logic on a whim tonight and found the beginnings of this song, just sitting there, from a previous flight or some other bored evening. I think I probably ruined anything good about this song with the new middle section, but I swear it sounded good in my head(phones).

The bouncing ball animation was created with the p5.js web editor, which is both awesome and easy to use. Don't take my word for it -- try out this code (not exactly the same as in the video, but probably cooler) and you'll see how fun p5.js / processing can be for kids of all ages.

function setup() {
  createCanvas(400, 400);
  background(0);
}

function draw() {
  circle(mouseX, mouseY,10);
}

An Afternoon with Arduino

For the last eight years or so, I've been carrying around an Arduino (not literally on my person, but, you know, amongst my treasures), waiting for just the right time to start tinkering with it.

That time, it turns out, was yesterday afternoon. This post outlines some of things I've learned so far.

Ard-what-now?

An Arduino is a microcontroller board. The board contains a CPU (central processing unit) along with some I/O (input / output) connections. You can think about it as a small circuit - a circuit that happens to contain a programmable computer on a chip. A chip that you can learn to easily program.

Here's a picture of my Arduino (of the Uno varietal):

Uno

I love the MADE IN ITALY mark in the upper left.

The microprocessor (the computer chip) is the long flat black rectangle near the bottom-right corner of the device. It has 28 pins (14 on each side). Along the top edge of the Arduino you can see a strip of black input pins - these are the Arduino's "digital" pins (meaning that they can either be "on" or "off"). Below the CPU on the bottom right you can see another 5 "analog" pins (meaning that they can receive analog / continuous signals), and then a few "power" pins to the left to provide voltage, ground, and some other stuff that I don't know about yet.

Arduino vs Raspberry Pi

At this point, you might be asking yourself, "How is an Arduino different from a Raspberry Pi?"

It's a good question, since both are affordable, adorable, tiny little computers that you can buy for about $30 bucks or less. But the Raspberry Pi is a full-on Linux computer. An Arduino is... not. Instead, the Arduino computer holds just one program at a time. It stores this program in durable memory, so that you can turn the Arduino on and off, and it will still "remember" its latest program. It's more like a single-purpose device -- except you can dream up and build that single-purpose as many times as you want.

Open-source roots

The company behind Arduino is a non-profit and the Arduino itself is open-source - which means that anyone can build an Arduino board themselves. The original idea behind Arduino was to make a simple device that designers and artists could use for rapid prototyping of physical computing projects that use sensors (aka inputs like a keyboard or mouse or motion detectors) and actuators (aka outputs like a display or printer or lights) to interact and communicate with us human beans. Cool.

Arduino is closely tied to the Processing community. In fact, that's a bit of an understatement, since you actually write Processing code when writing programs for the Arduino -- and, just like in Processing, these programs are also called Sketches. I was happy to see this, since one of my earliest computing classes was Jer Thorp's Introduction to Processing course (which I unabashedly recommend, by the way).

As I mentioned, anyone can download the open-source schematics for Arduino and build a board themeselves with basic components. But if you'd like to make your tinkering lifestyle easier, then I suggest picking up a pre-assembled Arduino from a retailer like Makershed or Adafruit. The kit I bought (eight years ago) is the MAKE: Getting Started With Arduino Kit -- the current version (v3) appears to be retailing for $79.99 bucks. IMHO, it's definitely worth it -- the kit comes along with a bunch of goodies that help you get started right away, like a breadboard, colorful wires, clickable switches, LEDs, sensors, and a friendly introductory book. I also picked up Arduino: A Quick-Start Guide by Maik Schmidt, and I've been enjoying this book as well.

Fun with LEDs

I believe you're legally required to write a program that blinks an LED on and off as your first project with Arduino.

If you asked me a few days ago about LEDs - yeah, sure, I know about LEDs. Those little red lights in things like my Game Boy. Stands for... light emitting... diode.

Great, you continue, what's a diode?

Um.

This is already one of the fun things about playing with Arduino. There are all sorts of basic electronics stuff that I sorta know about, but couldn't explain to a five-year-old or to a rubber duck on my desk. Or just don't know at all. But Arduino is helped me tackle these topics in a practical, tangible way.

So, let's take a look at an LED together.

LED

See the longer pin / leg sticking out of the red part? That's the anode terminal. The anode is the positive end of the LED. The shorter leg is the cathode - the negative side. Electrons will flow from the anode to the cathode when connected. You'll want to connect the positive end to something providing voltage, and the negative end needs to be connected to ground. All diodes are polarized, meaning they have these distinct positive and negative sides. And LEDs (light emitting diodes) happen to provide illumination when they're connected to an active circuit.

And they can be lots of pretty colors, too.

Okay, so here's our legally-required sketch for blinking an LED connected to digital pin 13 every half-second.

const int LED = 13;

void setup() {
    pinMode(LED, OUTPUT);
}

void loop() {
    digitalWrite(LED, HIGH);
    delay(500);
    digitalWrite(LED, LOW);
    delay(500);
}

Pretty simple, right? We first declare a constant variable for the pin we're using. The setup() function will run once per program, right before the loop() kicks off its infinite loop, so we'll just let the Arduino know that we want to set pin 13 to OUTPUT mode. And then during our infinite loop, we'll toggle the voltage to the pin by passing HIGH (5 volts) or LOW (0 volts) to our pin 13 using the digitalWrite function, pausing 500 milliseconds between these operations.

If you're coming from the Processing world, then this program structure of setup() and loop() should look very familiar, since it's literally the same.

The Arduino IDE provides an easy way to verify your programs compile before flashing them over to your actual Arduino, so I suggest clicking the Verify button first. This will catch syntax errors, like pesky missing semi-colons.

Next, we can set up our physical device.

I'm going to stick the LED into the Arduino, with the anode leg going into pin 13 and the cathode leg into ground. Note here that pin 13 is a special pin on the Arduino that has a resister built-in. If you try this with any other pin the Arduino, then the LED will burn out.

Finally, we can send our program from our computer to the Arduino over a USB connection by clicking the Upload button in the IDE. Your Arduino should flash happily once its complete, and then it's off to the infinite races.

Binary Counting

Look at that blinker. Pretty great, huh? Note that this gif definitely speeds things up a bit.

Putting the "S" in USB

So, as I continued building stuff, I inevitably found myself wanting to console.log the heck out of a program that wasn't working.

Let's talk about printing stuff with Arduino.

Your Arduino is connected to your computer via a USB cable. USB. USB. That has to stand for something, right? It does. It stands for "Universal Serial Bus." USB is a quote "industry standard" for communications between computers and peripherals. If you think back really hard to the time of Captain Marvel or even earlier, you might remember other ways that we connected peripherals to our computers -- like an dot matrix printer's parallel port or a PS/2 keyboard port. Well, in the time since Carol Danvers left us here to fend for ourselves, USB has taken over our hearts, minds, and wallets. But we're still using a "serial connection" when we're using USB devices - so we'll need to use the serial protocol to communicate with our Arduino.

In other words, if we want to send or receive info from our Arduino program, we need to establish a serial connection with the device. Here's how you do that in a Processing sketch:

const unsigned int BAUD_RATE = 9600;

void setup() {
    Serial.begin(BAUD_RATE);
}

void loop() {
    Serial.println("Hello, world!");
}

Baud rate, huh? I know this baud term, too. Modems had baud rates, IIRC. Some Wikipedia-ing and Google-ing reveal that baud rates are the rates at which information is transferred in a serial channel. In this case, with a baud rate of 9600, we're transferring a max of 9600 bits per second. 9600 happens to be the standard baud rate for Arduinos, but I believe you can choose a different rate.

To view your "console", you can click the "Serial Monitor" button in the IDE.

Hello

In addition to viewing received information, you can also send messages back to the Arduino in this monitor using the text input on the top panel and the Send button. For example, you might write a program that toggled an LED on or off based on a specific input key.

What if you don't want to use the Serial Monitor in the Arduino IDE? Maybe it's time to let the old ways die. I agree. If you're on a Mac, then you can try running the screen command from your terminal, specifying both the name of your serial connection to your Arduino and the baud rate.

screen <name_of_serial_connection> 9600

In my case, the name of the connection was /dev/cu.usbmodem14101, which you can find in the Tools/Port menu of the Arduino IDE.

Word of warning, however. If you close this terminal window, it won't close the sesssion, and you'll be unable to Upload new programs to your Arduino. This is called a "detached screen" and it's annoying. You need to quit the screen somehow, and you can use this command to do so:

screen -X -S <name_of_session> quit

Oh, to get the name of the detached session, you can type:

screen -ls .

This whole serial communications thing opens up some interesting ideas, since you can have two way comms between your Arduino and something else. Forget Alexa. Not-okay, Google. Go away, Siri. Now you can build your own talking robotic best friend, instead. Hopefully gets some gears turning for you, too.

Counting in binary with LEDs

In general, life-goal-wise, I've been trying to get better at thinking and counting in binary, so I decided to build a little binary counter for my next Arduino project.

const unsigned int LED_BIT0 = 12;
const unsigned int LED_BIT1 = 11;
const unsigned int LED_BIT2 = 10;
const unsigned int LED_BIT3 = 9;

long result = 0;

void setup() {
  pinMode(LED_BIT0, OUTPUT);
  pinMode(LED_BIT1, OUTPUT);
  pinMode(LED_BIT2, OUTPUT);
  pinMode(LED_BIT3, OUTPUT);
}

void loop() {
  result++;
  if (result == 16) {
    result = 0;
  }
  output_result(result);
  delay(500);
}

void output_result(const long result) {
  digitalWrite(LED_BIT0, result & B0001);
  digitalWrite(LED_BIT1, result & B0010);
  digitalWrite(LED_BIT2, result & B0100);
  digitalWrite(LED_BIT3, result & B1000);
}

Binary Counting

I'm not sure why the red LED isn't as bright as the other three LEDs. I tried swapping it out with another LED to no avail. But, hey, other than that, this thing works!

I also learned that breadboards are great. Being able to run all the cathode sides of the LEDs to the bottom negative row of the breadboard, and then only connecting that row once to the Arduino's ground port is pretty darn helpful. I have more to learn and appreciate here, for sure.

Also, this is the first time that I've really leveraged the power of the bitwise-and operator. I'm taking my result and bitwise-and it with a binary number that represents a binary digit (1's, 2's, 4's, 8's) for each of the LEDs. The bitwise-and operation returns true if result and our binary number both contain a 1 for the given binary digit. For example, let's look at the number 3

3 & B0001; // true
3 & B0010; // true
3 & B0100; // false
3 & B1000; // false

The final trick here is that digitalWrite function transforms true boolean values into HIGH (turn on the LED) and false into LOW (turn off the LED). So, for the number 3 the LED for the 1's digit and the 2's digit should be lit, and the 4's and 8's should be off.

That's pretty awesome and makes this code very concise. There's much more to explore here for me.

More tinkering

So, after a mere afternoon, I've learned a ton and had quite a bit of fun along the way.

What's next, you ask? Well, resistors are still perplexing. I'm not sure yet how to determine what level of resistence is needed for a given situation. I've already fried an LED (a delightful puff of smoke wisps out during its last gasp of life), likely for this very reason. It's also really hard to read those colorful bands to try to determine their resistance level. This seems like it could be a great little computer vision / deep learning app. Or perhaps I should just use my multimeter more regularly.

I'm also thinking more about the difference between analog and digital signals. Digital is binary (either on or off), whereas analog is continuous. Most of what we observe in life is an analog signal. So when we choose to digitize them, we need to choose specific moments to "sample" the values of the continuous signal. The Schmidt book explained that an audio CD takes a sample every 44,100 per second (or 44.1 kHz). Maybe this is why vinyl is back.

I thinking that my obvious next project here with Arduino is to make an alarm clock with binary numbers. There are tons of neat examples of this project across the web, and I think it could be a good way to learn / improve my soldering skills, as well as my quick mental binary counting, especially while groggy in the middle of the night.

Novels with Giant Possibly Magical Libraries

I'm currently reading a fantastic novel where the protaganist - who is in her teens and lives in a sort-of convent for sightseers in the middle of a glacier - is asked by the elders to choose a role for part-time work. Our hero considers two options:

  • Become a pilot of paper-mache, semi-alive airplanes controlled by whistling
  • Become a librarian

I held my breath as I read further: choose The Library!

Why Libraries?

There are two things that, when I encounter them in a book, immediately cause me to fall in love.

  • The word palimpsest
  • A giant, possibly magic, library (extra points for a Forbidden Section or two)

The two are not unrelated. A palimpsest is a book that has been one or more books before, with the older knowledge hidden just beneath the surface of the parchment, waiting to be unearthed. A giant library must, invariably, contain books with once-known, now-forgotten knowledge, just beyond that locked door over there.

But I have the key...

I hereby present a list of the very best novels featuring giant libraries filled with secrets.

My List of Novels with Giant Libraries

*Indicates that I haven't read this book (yet), but rest assured that it was recommended by a semi-close friend, cousin of mine, or Hacker News commenter.

Let me know on Twitter (@whatrocks) if I'm missing anything and I'll update the list, almost like a palimpsest.

Borrowing Library Books for Your Kindle

Basically, do it. It's super easy. I'll show you how in this post.

How to borrow library books for your Kindle

  1. Obtain a Kindle from Amazon. I'm using the Kindle Paperwhite with Special Offers, which I recommend. The special offers are just ads for random books, and they only appear on the lock screen of the Kindle. Who knows? You might even find something you like with the offers.
  2. Obtain a library card number from your local library. This takes a few minutes in person, but I'm sure you can also do it online. You'll probably need some proof of residence, like a driver's license or some utility bill. Better be safe and bring both.
  3. Sign into your library's ebook manager on the library's website using your library card number. Most likely they are using a service called Overdrive. You'll probably also create a PIN number when you register for your library card, so write that down somewhere!
  4. Search for a book on Overdrive (or your library's respective ebook service), and then you'll be able to either borrow or place a hold for it. The San Francisco Public library, for example, allows you to borrow or place holds for up to something like 20 books at a time!
  5. Once you've borrowed a book, click Read Now with Kindle. You'll been taken to the Amazon page for the book, and you can send the ebook directly to your Kindle. Next time your Kindle connects to wifi, the borrowed book will be downloaded.
  6. Read, rinse, and repeat. I like to have several books borrowed at a time, with a few holds as well, so that there's always something coming down the pipe.

๐ŸŽ Placing holds for books is like sending a gift to your future self

Imagine waking up to this email:

email

It's like Christmas morning! Once you click that link, you'll be taken to your Overdrive account:

overdrive

Even before you've had your (first) coffee of the day, you can probably manage to click that Read Now with Kindle button:

amazon

Click Get Library Book, and you're done! Your morning commute just got a little bit nerdier.

borrowed

Borrowing Audiobooks

You can do this, too!

There's a great app called Libby that is somehow affiliated with Overdrive, and that's what I recommend using for listening to library audiobooks. Everything that you rent through Overdrive, whether ebook or audiobook, will automatically appear in your Libby app (once you sign into Libby with your library card). This is helpful for when you inevitably forget your Kindle at home (there's also a Kindle phone app, but I haven't used it recently).

I still haven't entirely embraced the audiobook lifestyle, but it's something on my mind for 2019.

But what about how good paper books smell?

I'm a paper book monster. And, yes, the smell is half the reason. But public libraries are vitally important -- and were vitally important to my childhood. I'm happy to be bringing them back into my adult life, even in this electronic way.

I'm also still buying an insane amount of paper books, from local booksellers whenever possible. Not even Marie Kondo can stop me from that.

The Walkingman Collection

Dec 2021 Update: I've migrated this site to syte, and the previous (flaky!) Instagram integration is now gone. Hopefully I'll figure out a nice solution for displaying these photos in the future. Thanks! -- The Webmaster

I've pulled all my Instagram #walkingman photos into a handy little page. Check it out.

So long as the Instagram API continues to play nice (no guarantees), then this page will stay up-to-date as my travels continue.

walkingmen

I'd love to learn more about who designs each of these little creatures for a given city or country. What's the decision process like? Are they meant to capture the spirit of the people in some way?

This is a coffee table book waiting to happen.