Graph of IQ vs. US Household Income Percentiles

graph (1)

Here’s a graph that I made of IQ vs. US Household Income percentiles.  In other words, I looked up the percentiles for IQ and cross-referenced them with the percentiles for US Household Income.

Of course, financial status is a function of many factors such as intelligence, luck, hard work, and life choices.  Perhaps the value of this graph is in indicating how much financial status is affected by those other factors.

References are IQ Comparison Chart and United States Household Income Brackets and Percentiles in 2017.  I made this graph by using Create a Graph.

(And to promote my science fiction novel:  The Wizard from Earth.)

Posted in Uncategorized | Leave a comment

Structures: Or Why Elon Musk Recommends This Book


Elon Musk has provided us with a list of fourteen favorite books that inspired him, and amid fantasy novels such as Lord of the Rings and Hitchhiker’s Guide to the Galaxy and biographies of Benjamin Franklin and Albert Einstein is a book on material science entitled, Structures: Or Why Things Don’t Fall Down.

Structures was published in 1978 and was written by J.E. Gordon, a British material scientist. In the forward, Gordon refers to the book as, “. . . an elementary book about structures . . . stripped of its mathematics.”

Structures was one of only two books on Musk’s list that could be termed ‘technical,’ which caused me to think I should read it. And I wasn’t the only one who came to that conclusion. There were over two dozen holds on the single copy in the local library system, and I had to wait over a year to get my hands on it.

So why did Elon Musk recommend an obscure popular science book?  Given that the book is almost forty years old, is it still relevant and useful to today’s engineers? I’ll provide a brief overview here so that you can decide for yourself.

All Structures, Great and Small

As the complete title is, Structures: or why things don’t fall down, you might think that the book is specifically about buildings and bridges. Author J. E. Gordon, however, simply describes a structure as, “Any assemblage of materials which is intended to sustain loads,” and thus the book covers a broad range of subjects whose only connection is the application of the basic structural concepts of stress and strain.

For example, Gordon discusses design and operation of archery bows, why chariots had their wheels removed when they weren’t in use (because they tended to deform under loads), and the history of catapults — such as a Roman admiral who won a battle by hurling pots filled with snakes (which doesn’t have much to do with material science but makes an interesting anecdote).

Even farther from buildings and bridges, Gordon spends a fair portion of the book discussing structure in animals and plants. “Nature having invented life . . . it became necessary to devise some kind of container in which to keep it.” So he starts with the structure of the cell, and goes on to skeletons, and why plants are often better armored than animals (weight of armor affects mobility) and why birds have feathers (they give the wing a better lifting shape without adding excessively to weight).

The book also discusses the roles of the Poisson Ratio and Wagner tension field (which he explains) in dress design, how to keep boilers from exploding, and how to keep wings from twisting off airplanes (and how trying to keep wings from twisting off airplanes can cause even more wings to twist off airplanes).

While some of this discussion is technical, there are also poignant stories, like the tragic tale of the H.M.S. Captain, a nineteenth century combination sail and steam ship that was designed by a naval captain to his personal specifications after a massive publicity campaign, and which promptly sank in a mild squall with the loss of 472 lives and only seventeen survivors (the designer-captain having gone down with his ship).  Gordon writes that due to ‘muddling,’ the ship was about 15 percent overweight.  “If this had not been the case it is at least possible that the ship would have been a success and comparatively safe.”

But yes, in accord with the title, a lot of the book is about structures, and specifically, why those structures don’t fall down. So you learn about tensile strength (hanging cables) and compression (stacking things). And it turns out a lot of civil engineering isn’t intuitively obvious. For example, masonry buildings have enough compression strength to be built much taller than they were in ancient times, but stability problems arose. And why don’t cathedral arches collapse? Because of the statues on the sides. Really. Seriously. Who knew?

The Structure of Structures

Despite the assertion in the forward, there is a bit of mathematics sprinkled throughout the book. Not as much as there would be in a college textbook, but some of the algebraic formulas would keep you busy at a calculator for a few minutes if you didn’t let your eyes glaze over them (like I did). For the most part, they don’t get in the way of casual reading.

And for the most part, the book is fairly light reading. It’s written in a humorous style, which you can see from the chapter titles. Here’s a couple: Chapter 5: “Strain energy and modern fracture mechanics — with a digression on bows, catapults and kangaroos.” Chapter 12: “The mysteries of shear and torsion — or Polaris and the bias-cut nightie.”

Gordon also avoids dryness by focusing on the human drama behind engineering, relating how Robert Hooke, who originated Hooke’s Law (Strain is proportional to stress), was a ‘lady’s man’ disdained by Isaac Newton for dirtying the noble pursuit of science with the shabbiness of practical application, and how Galileo, forced by the Church to recant his discoveries in astronomy, spent his days under house arrest investigating the science of structures, “ . . . as being, I suppose,” Gordon writes, “the safest and least subversive subject he could think of.”

Philosophically, Gordon stresses a number of themes, and one of the key ones is to contrast theory versus experience. He is fair to both sides. He notes that nineteenth century engineers who knew little theory built bridges that stand today, while modern bridges could not be built without rigorous mathematical analysis. Even then, mathematical analysis is insufficient to identify local discontinuities that can lead to crack propagation and structural failure. (Although in the time since the book was written, computer simulations may have gotten good enough to address this concern.)

The Book and Elon

So why would Elon Musk recommend this book above the countless other books that he’s read? Perhaps one answer is that the book was published and enjoyed its heyday at the time when he was a kid. We tend to best remember books from our youth, and because we’re impressionable at that age, we naturally are more impressed by books we read then than at later stages in our lives.  But I think there’s more to it than that.

In researching this article, I came across an interview in which Musk is asked what he would do to fix the traffic problem on an LA freeway. He suggests double-decking the existing road with prefabricated sections, and the interviewer asks, “Would that appeal to your sense of aesthetics?” and Musk quickly replies, “We would make it look nice.” This sensitivity to aesthetics is also apparent in the design of Tesla cars and the Dragon capsule and is right out of the last chapter of Structures, where Gordon laments the loss of aesthetics in the pursuit of efficiency: “Is it not fair to ask the technologist, not only to provide artefacts which work, but also to provide beauty, even in the common street, and, above all, to provide fun?”  This view of aesthetics as both important and fun clearly influences Musk’s design philosophy, and it has been a successful business strategy for him.

But also, there’s a lot in Structures that has practical application to what Musk is doing with SpaceX and the Falcon rockets. In many ways, rockets are like buildings — buildings as tall as skyscrapers, that must be able to endure gravitational stresses many times higher than normal and vibrations greater than most earthquakes, that despite the need for immense structural strength must be made as light as possible or they won’t be able to do their primary function, which is to fly faster and farther than any vehicle ever made. Gordon devotes only a few words in Structures to rockets, but if you’re aware of the engineering considerations relevant to all structures, you will be aware during reading of how much of the book is critically relevant to rocketry.

Structures: Or Why Things Don’t Fall Down may have waned in popularity over the years, but thanks to Musk’s recommendation it is enjoying a revival and is a currently a bestseller on Amazon. The ninety-three reviews (at current count) rate it between four and five stars. So Elon Musk isn’t the only person who finds this book worthwhile. I think you will too.

Posted in book review | Tagged , , , , , | 1 Comment

Multi-mode pen light: ATTiny85 with RGB LED


This is a bread board prototype of a multi-mode pen light. It shines white, red, green, and blue light. Intensity is adjustable. Strobe, emergency flasher, ‘psychedelic,’ and candle simulation functions. It’s powered by a USB phone battery charger pack and uses an ATTiny85 as the microcontroller.

Here it is in action:

Here’s the schematic:

RLM 85

UPDATE:  And here’s a sketch of what the completed flashlight might look like:

rlm 85 pen light


Posted in Uncategorized | Tagged , , , , | 1 Comment

Beyond the Blink: RGB LED multiple lighting effects with arduino, push button, and potentiometer

Ever want to do more with an LED than just blink? This circuit and source code demonstrates some creative possibilities for lighting effects with an RGB LED.

CC has descriptive subtitles. Sorry for the poor phone video quality.

Here’s a circuit diagram (for common anode LED):

Here’s the source code:

version 9.1 / September 2017

Written by Joe Schembrie aka Engineer Zero.
In the public domain.
No attribution necessary.
Alter as you see fit.

Controls an RGB LED in multiple modes. A push button changes
the mode and a potentiometer is used to adjust intensity,
rate, and color.


I used a common anode RGB, for which
analogWrite() goes HIGH for 0 and LOW for 255. You'll have
to revise your code accordingly if you use a common cathode RGB.

Lighting Mode Descriptions:

1 Candle
2 Red
3 Blue
4 Green
5 Tricolor
6 Strobe
7 Pure White
8 Broken Light
9 Yellow flashing (caution)
10 Psychedelic
11 Pulse

See my blog, for more fun stuff.


// here are the pin number assignments

int blue = 11;
int green = 10;
int red = 9;
int potpin = 3; // the pin the potentiometer is on
int button = 7; // the pin the button is on.

// various variables

int potval = 0; // adjusts for magnitude and rate
int choice = 0; // your mode selection

// these 'prev' values are for the psychedelic choice

long rprev = 128;
long gprev = 128;
long bprev = 128;

void setup() {

// initialize the pwm pins as outputs.
pinMode(red, OUTPUT);
pinMode(green, OUTPUT);
pinMode(blue, OUTPUT);


// seed the random number generator


void loop() {

// read the pushbutton to see if it's been pushed
int val;
val = digitalRead(button);

// val = HIGH means the button has been pushed
// and the mode is to be changed.

// SELECT CHOICE //////////////////////////////////////////////////
choice = choice + 1;


// indicate mode transition with blue flashes
for(int i = 0; i<5; i++){


// change this if you want more modes

if (choice == 12){
choice = 0;

//TIME TO LIFT BUTTON //////////////////////////////
// (for debounce)

while (val == HIGH){
val = digitalRead(button);


// read the potentiometer value
potval = analogRead(potpin);

// OFF


// RED

analogWrite(red,255 - potval/4);


analogWrite(green,255 - potval/4);


analogWrite(blue,255 - potval/4);

// tricolor
int tricolor;
for(int j = 0; j<4; j++){
tricolor = red;
tricolor = green;
tricolor = blue;


} // end of tricolor



//this is white
analogWrite(red,255 - potval/4);
analogWrite(green,255 - potval/4);
analogWrite(blue,255 - potval/4);

// Oh no, your light is broken!
int mag8 = random(0,255);
int d8 = random(0,100);

// Caution-warning yellow flashing light


// Psychedelic

// When tweaking code, careful with variable types.

long rnew = random(256);
long gnew = random(256);
long bnew = random(256);
long rval;
long gval;
long bval;

for(int i; i<101; i++){
rval = rprev + long(i *(rnew - rprev)/100);
for(int i; i<101; i++){
gval = gprev + long(i *(gnew - gprev)/100);
for(int i; i300){
p = blue;
p = green;
for(int i = 0; i<256; i++){
for(int i = 0; i<256; i++){

} // end of choice 11

} // end of loop, loop, loopy-doop!


void flicker(){

// makes a flickering candle light

int k = random(0,100);
potval = analogRead(potpin);
float p = float(potval)/1023;

int rmag = 255 - (15 + 155 * k/100)*p;
int gmag = 255 - (10 + 55 * k/100)*p;


int d = 50+300 * random(0,100)/300;




void tricolor(){

// transitions between red, blue, and green lights






Posted in Uncategorized | Tagged , , , , , , , , | 1 Comment

Making a flickering candle with an RGB LED and an ATTiny85 chip

Normally you don’t use an ATTiny85 to drive an RGB LED, because an RGB LED needs three pulse width modulation pins and the ATTiny85 only has two.  However, for the application of a flickering candle, you need only two PWM pins, the red and the green, and for that the ATTiny85 does the job just fine.

Unfortunately, my smartphone camera doesn’t do the color and intensity changes justice, but here’s the video:

Here’s a photo of the setup in the video:


As you can see, the through-hole chip is puny compared to the LED.

And here is an Arduino Nano pressed into service as an ATTiny85 programmer:


In case you’re familiar with using Arduino but unfamiliar with how to use an ATTiny85, Matt Richardson made a great video on the topic here:

To avoid the hassle of shuttling the ATTiny85 chip back and forth between the programmer and application breadboards, I recommend first testing your program (aka sketch) on your Arduino until it’s debugged, then moving the program from the Arduino to the ATTiny85 .

When converting a program from the Arduino to an ATTiny85, remember that you have to translate pin numbers.   I made a conversion chart here for doing just that.


If you like reading science fiction and fantasy, you might enjoy my ebook trilogy beginning with The Wizard from Earth.

Posted in Uncategorized | Tagged , , , , | 5 Comments

Controlling Multiple RGB LEDs with Smartphone via Bluetooth


Many people have done projects similar to this where they use their smartphone to control an RGB LED. My project has some twists. First, I traded color variation for intensity variation. Second, I routed the Arduino PWM signal pins through power transistors so that I could drive multiple LEDs. Third (for now), I’m using phone charger battery packs so that eventually this thing can be mobile.

Here’s a video, I apologize for the quality, but it’s short and gets across the idea:

Here are some photos of the apparatus in close up. We’ll start with my smartphone, an LG K8V, as ordinary as they come:


The app is called ‘color control’ for the current icon. I used app inventor to create it, and also referenced a lot of online examples. App Inventor is a great resource that makes programming apps easy, and it’s great that so many people are willing to share their code! I have some tweaks to my code, which I’ll get around to sharing once it’s stable and if anyone is interested.

And here is what the app screen looks like:


Connecting to Bluetooth is simply a matter of touching the button, then selecting the Bluetooth device from a list. Oh, and remember to turn on your phone’s Bluetooth!

Here’s the Bluetooth hardware set-up:


The Bluetooth device is an HC-06. Note the resistors, the receive pin can only take 3.3 volts while the Arduino is sending 5 volts, meaning that you have to use a resistor bridge.

You all recognize the Arduino:


I’m using an Uno R3 here, but I’m planning to go to a Nano, which is smaller and less expensive and, I hope, less at risk of instability when supplied power is limited to five volts. We shall see . . . .

Here are the power transistors:


They are BD139s, NPNs that allow 1.5 amps through the collector-emitter path, or enough to power 25 RGB LEDs. The Arduino pins by themselves could only power one LED, while ordinary transistors would only power three or so. Power transistors are cheap, so no big deal.

The green patch in the upper right hand corner of the breadboard is the USB power breakout. A very handy thing to have, I wish I’d known about them when I was working on Project Grisbot (my robot) many years ago, I could have used phone charger battery packs in lieu of 9 volt batteries back then.

And here are the RGB LEDs:


I used common-anode RGB LEDs because I wanted the transistor at the ‘bottom’ of the circuit branch. Thus current pours in from the battery pack into the LED, then branches into the resistors, and then the resistor branches of red, green, and blue respectively combine to enter the collector node of the respective transistor, where the signals are modulated by the Arduino at the base.

BTW, all the resistors here are 200 ohm. I calculated that to keep the current through the LEDs down to 20 ma.

Anyhow, that’s the project as it stands. The goal is to make this prototype into something that is truly compact and mobile. Plans include using an Arduino Nano and a real circuit board. The big changes, though, will come in the programming as I intend to make it possible to save and replay files that are sync with music.

Posted in Uncategorized | Tagged , , , , , | Leave a comment

Ultrasonic Toggle Switch Source Code (Arduino)

// ultrasonic toggle switch
// Joe Schembrie aka 'Engineer Zero'
// comments 6-23-2016

// the circuit for this sketch consists of a yellow and green LED and an ultrasonic distance sensor (pinger).
// when a hand approaches the pinger, the yellow light comes on with the approach.
// when the hand gets close enough, the value of green is toggled.  
// IE, if the green LED was off, it turns on.  If it was on, it turns off.

// to see this in action, visit

// The green LED toggles only once while the hand is near. 
// The hand must be retracted far enough so that the yellow light goes off
// for the green LED to be toggled again.  This prevents 'bouncing.'  

// NOTE:  In some respects, this device seems to work best when the yellow light is disconnected.
// NOTE ON NOTE:  I wrote the above note a couple years ago AND DON'T REMEMBER WHY.

// Now for inclusion of the library.  
// the NewPing.h library is available on the Internet.
// I did not write it.  I cannot answer questions about it.
// It comes with documentation on the Internet.  
// Google away!

#include <NewPing.h> 

#define TRIGGER_PIN  11  // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN     10  // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.

// now to stuff that I wrote.
// here are some very important variables

// dis is distance of hand to sensor.  greenstate is state of green light.
// toggle is a variable that gives approval to toggle.
// Note that 'toggle' does not by itself trigger a toggle.  
// It only gives 'approval to toggle.'  

unsigned int dis;
int greenstate = 0;
int toggle = 10;

void setup() {
  // put your setup code here, to run once:

pinMode(2,OUTPUT);  // yellow is 2
pinMode(3,OUTPUT);  // green is 3
pinMode(11,OUTPUT); // pins 10 and 11 are used by NewPing



void loop() {
  // put your main code here, to run repeatedly:
// NewPing stuff . . . 


unsigned int uS;
uS =;


// . . . end of NewPing stuff.  Now onto my stuff:

// the following code sets the zone value according to distance.
// after toggling, toggle approval is de-activated but 
// is re-activated if the hand is retracted to zone 0.
// this prevents nuisance toggling (bouncing).

int zone;

// zone = 0 means the hand is far enough away that the sensor doesn't react to it.
// toggle approval is granted.  
// I set the distance at 40 cm.  You can experiment with distances as you please.

  zone = 0;

// zone = 1 means the hand is close enough to turn on yellow light.

  zone = 1;

// zone = 2 means the hand is close enough to toggle the green light.
// the 10 cm distance is open to your choice.  

if (dis<10){
  zone = 2;

// Now, I vaguely remember that the reason for the following test had something
// to do with the quirkiness of the sensor.  Sometimes it fails to read and
// reports a zero distance.  The following test prevents that from causing problems.

  zone = 0;
  toggle = 10;

// now we take care of yellow light.  
// It's pretty simple.  If you're within a certain distance, it's on.  Otherwise, off.



// we toggle the variable greenstate (and, most importantly, the green light)
// if we're in zone 2 and toggle is 10.
// why these values?  It will become apparent in later context.  
// zone 2 means we're close enough to toggle.
// toggle = 10 means go ahead and toggle.
// toggle = 0 means don't toggle.
// greenstate = 0 means the green light is OFF.
// greenstate = 100 means the green light is ON.
// 'toggle' is a variable that 'approves' toggling the green light
// only ONCE when you're close to the sensor.  It's then set to 0
// and your hand has to move away in order for it to reset to 10.
// this prevents bouncing.

int k = 0;

// now, you're probably also wondering about this 'k' business.
// the k variable is a handy way to avoid making a complex IF statement.
// Maybe it's me, but sometimes I just can't get multi-condition IF statements
// to work on the Arduino.
// So instead, I use individual IF statements to create flag variables
// and then add the flag variables together to create a 'master flag variable'
// which I can then test in a simple one-variable conditional statement.
// So k is for 'kludge.'  But it works . . . .

k = toggle + zone + greenstate;

// k = 112 means that the toggle (=10) is approved, we're in toggle zone (=2) , 
// and the greenstate (=100) indicates the green light is ON.

  greenstate = 0;
  toggle = 0;

// k = 12 means that the toggle (=10) is approved, we're in toggle zone (=2) , 
// and the greenstate (=0) indicates the green light is OFF.

  greenstate = 100;
  toggle = 0;

// these two statements then toggle the green light 
// (and circuits activated by the same pin).
// note that for all other values of k, no action is taken.  

// And that's all there is to it!!!



Posted in Uncategorized | 1 Comment