Things I Learned

The Make book “AVR Programming” is fantastic. In an attempt to serve as many people as possible, they provide advice and many different paths to get setup. Here are some lessons that I learned that might save you some time:

  1. Using the Arduino as an AVR programmer (Sub-Optimal). While the book says that it is “easy” and “straightforward”, my experience was that this was not the case. I found that other smart engineers had similar experiences. So while using an Arduino is possible to program a chip, it is “not worth the time” and “an experience in forcible hair removal.”
  2. So if using an Arduino is out, what should I use?

This Thing:


While it is developed to put ATTinys directly on it, I soldered some female headers on the end, and it works like a charm! It follows the book really well, so if you are a newbie to the programming of AVRs, this is a quick path to success.

The book also discusses different toolchains. I was working with a Windows machine, and hat worked for me:

  1. Program in the Arduino IDE – I was familiar with this so this was my first step. I could make sure that I didn’t have any errors in a familiar environment.
  2. Migrate programs to the Programmers Notepad
  3. Download avrdude, and flash programs using the “make flash” comamand in the cmd prompt.
    1. If you are following the book, this will make sense. If not, this might be Swahli to you.

Word of warning:

This thing is twice as expensive, and harder to use than the product above. As I advance my skills, maybe I will realize what I am paying the extra money for, but as of now it has been relegated to the far reaches of my desk.

Playing with AVR Programming

My friend Professor Soltys invited me to a talk at a local Hacker Space, the Solid State Depot. The subject of the talk was intermediate AVR programming, but it was pretty advanced, and just the spark to light my afterburner for a deeper dive into the world of microcontrollers.

During this talk, I was able to meet with Electrical Engineers, Robotics Professionals, and hobby makers and learned about a new Rabbit Hole… programming the brains of Arduino (ATMEGA 328p chip), with C. This book was recommended to me, and so far has been fantastic. There are some intricacies that might trip up some other people, so I will try to highlight what I have learned in my following posts.

Humidity sensor

Oh the Humidity sensor. Students think that it should be so easy, but my friends are sorely mistaken. Of all of the sensors that student’s use, this little guy seems to give them the most problems.


The first issue is its name – it is sometimes known as the DHT22, and used to be called the RHT03. Names aside, I think that students difficulties arise because this product is not really well documented at Sparkfun – it’s hard to be great all of the time I guess!

Adafruit on the other hand has a great library supporting this. In fact, Adafruit’s DHT library is so good that it is actually used as an example on the Arduino “How to Make a Library” tutorial and API style guide. If you didn’t click the first link, the library can be found here.

But Wait!

Even if you install the DHT library, you still are not done. The DHT library requires the use of the ADAfruit Unified Sensor Library, so make sure to install that into your Arduino Libraries folder as well.

Once you have the Libraries up and going, it is pretty easy to use the DHT sensor. Instead of re-inventing the wheel, I will just point you to this Bildr tutorial.

If you spend time looking through the datasheet of the humidity sensor or the example code from Sparkfun, you will see things that send project makers like me into a cold sweat  (in hindsight I would have done an Electrical Engineering minor) “MaxDetect 1-wire bus is specially designed by MaxDetect Technology Co., Ltd. , it’s different from Maxim/Dallas 1-wire bus, so it’s incompatible with Dallas 1-wire bus.”


Therefore the libraries and code that Adafruit started and Bildr finished allows students to use the humidity sensor in their projects for humidity – without that EE degree.

So if you are here and measuring Humidity – make sure to thank the BFGs at Adafruit and Bildr for letting us stand on their shoulders for a little while.



Photo Studio

To better document student projects, I setup a little (20″ x 20″) photo studio outside of my office. Here is a photo of my watch taken with no filter on my iPhone. Not too shabby!

test-watchAnd here is a little Claw Robot that I built and use for class demonstrations:



And finally, the Claw Robot as taken by someone who markets SUVs:claw-bot-2

I CRUSH you. You buy an Escalade with rich Corinthian leather… I still CRUSH you.

Note: Yes, I know Richardo Montelban sold Corinthian leather in the Chrysler New Yorker – my poetic License was revoked a long time ago.

Comparator Nightlight

After years of making my nightlights out of Arduino components, I decided to make one using my knowledge of comparators. I started with a schematic from the illustrious Dr. Ruben, but then tweaked the resistance values to be able to adjust the thresholds with a 10k potentiometer, a 10k photocell, and two 10k resistors that I had available.

Nightlight schematic – straight from the Good Doctor Ruben.

Since one of my goals was to use this post as an opportunity to show students a typical progression with circuit building, I built the first circuit on a large breadboard. This allowed plenty of room to make mistakes. Without having to worry too much about placing the wiring, I could free my brain up to think about the fundamentals of comparator circuit building. During this time, I realized that the best way to build the circuit was with a potentiometer to allow the user to select the darkness threshold.

After ensuring the circuit was performing as desired, I wanted to free up my big, expensive breadboard for other projects. Therefore I intended to solder the circuit onto a little protoboard that I had lying around. However while laying out the board, I realized that I wanted to ensure that my connection wires were straight (for aesthetic reasons). Therefore I migrated my large circuit to a mini bread board and now really paid attention to wire placement.

Once I had the wire layout, I was ready to migrate my circuit to a protoboard and solder the connections. Interestingly while soldering my board, I noticed that my wiring was blocking the mounting holes. This required a bit more unsoldering/re-soldering than I was hoping! C’est la vie de l’ingénierie.

And that, as they say is a wrap. For future work, I would like to use  Fritzing/Eagle/Altium and to make a surface mount device circuit board. But for now I am on to other things!

Merci Dr. Ruben and Dr. Reamon for the help with Comparators. Bon!

EZ Stepper Code

So some students were wondering how to get the Sparkfun Easy stepper driver working. I pointed them to some Bildr code ( After testing it, while the wiring was a good start, the code did not work optimally.

Therefore I made some simple code that seems to get the Easy Stepper Driver saying “Hello World”:

/*This code controls a stepper motor with the
EasyDriver board for 1 step
int dirPin = 2;
int stepPin = 3;

void setup()
pinMode(dirPin, OUTPUT);
pinMode(stepPin, OUTPUT);
void loop()
digitalWrite(dirPin, LOW); // Set the direction.

digitalWrite(stepPin, LOW); // This LOW to HIGH change is what creates the
digitalWrite(stepPin, HIGH); // “Rising Edge” so the easydriver knows to when to step.
delayMicroseconds(500); // This delay time is close to top speed for this
// particular motor. Any faster the motor stalls.
//End code

If you change the dirPin to HIGH, this changes the direction of the stepper motor. What happens if you try it with a “For” Loop?


Plastic Cup Speaker

While minding my own business on a Friday afternoon a couple of weeks ago, a group of students came to my office. They were having some trouble with an assignment for 5th graders – make a yogurt cup speaker.

During the testing, an important lesson was learned. They were using a coil of copper wire with little resistance (0.01 Ohm) – but often commercial speakers have a resistance of 4 or 8 ohms. By using a wire coil with less resistance than this, they may have damaged their radio. If it is indeed damaged, it will not be the first loss in the name of science.

With the lessons learned, I created a small speaker out of a plastic cup using a strong mini magnet (McGuckins), a coil of wire (found around the lab), and the cup from my lunch at Tokyo Joes (Dark Chicken Bowl – best deal):

Note: If shave and a haircut still only costed 2 bits, my shaggy dome would probably be less unkempt.