Wednesday, October 1, 2014

Getting Back to Blogging after Publishing the Book

As blog readers are probably aware, I have been working on a new book for Maker Media called Getting Started with Adafruit Trinket.  It's been a labor of, well, work.  It has been a great experience but I'm ready to get back to a wider array of projects.

The book details use of the Trinket - an ATtiny85 breakout board from Adafruit Industries.

Here is the back and front cover.  It has changed over the last few months, the title a bit, the cover definitely new and a departure from many Make books.  Another departure is color - the inside is printed in color vs. black and white for most Getting Started books.  This allows you to really see the wiring and the projects.

The source code and the illustrative pictures have been posted on GitHub at

If you would like to see the Adafruit "Ask an Engineer" webcast in which I join Limor "Ladyada" Fried and Phil Torrone talk about many things including the book, here is the video:

Please excuse my actions and the bags under my eyes!  I had been awake for like 22 hours at that point and I need my beauty sleep after 16!  Curse transatlantic flights!

The book is available in final release via ebook in  ePub, Mobi, and/or PDF formats from O'Reilly at or preorder the paperback from  It should be out by mid-October!

Friday, May 16, 2014

Your Perfect Microcontroller

With thoughts of the Arduino Zero floating around, it begs the question: has anyone done any customer surveys to know what type of microcontrollers people actually want to buy?  Ask customer?
I'm sure certain companies have listened to the market.  Limor Fried of Adafruit has a good track record for introducing controller form factors that are popular.

The Arduino Zero is a collaboration of Atmel and Arduino.  But nothing that has come out to date has said "we introduced this specifically targeting the customers for ______".  There is some market-speak for Internet of Things and wearable usage.  Who is going to put an Arduino Zero board in a wearable?  If it costs $5 then people will try but this thing is shaping up to be big and probably at a price point that hurts.

So I open it up: if you had your choice of a perfect microcontroller board, what would you like to see?


  • Large, small, "medium", compact, cubist, "fits in a ___"?
  • Lots of input/output pins?  Just enough?
  • BIG ONE: 5 volt pins or 3.3 volt pins? (or 3 volt, 5 volt tolerant!)?  Current per pin (Zero's 7 milliamps, Uno's 40 milliamps, or other)?
  • Interfaces (serial, I2C, SPI, CAN, Ethernet, debug, USB)?
  • Power?  Solar, LiPo/battery, 5 volt, 3.3 volt?
  • Bare metal real-time software (Uno etc.) or Linux, both, other?
  • Other features?
In a following post I'll compile a user-desired board and my next dream board.

Thursday, May 15, 2014

The New Arduino Zero - The Good and The Bad

Enough articles are being produced on the new Arduino Zero, including the blog post and the press release, that I need not just repeat what others have written.

Today I compile comparisons on useful features, possible target audiences, and drawbacks.  If you believe I've missed something (or plain wrong), please post comments as a lively discussion would be good.

Target Audience:

  1. Adopting the Arduino shield pinout would imply that use of the hundreds of Arduino shields in existence would be expected.  Great, but it doesn't imply this at all and this will confuse new folks.  The voltage at which the pins signal is at 3.3 volts, not the Arduino Uno's 5 volts.  So you can count the number of 3.3 volt shields on maybe two hands and the number of autoswitching 3.3v/5v shields on one hand.  This, coupled with the paltry 7 milliamps per pin and this is not a beginner's board (drawing too much current would damage the processor and it is not replaceable like the ATmega 328p on most Unos).
  2. Debugging port is definitely an advanced feature and very welcome in more powerful boards.  Anyone doing more than  a "Hello World" program knows that stepping through code and watching what it does is professional programming, something possible 30 years ago on other processors.  This can be for seasoned coders and for beginners with very good instructions and a well-written IDE like the Adafruit python program for Raspberry Pi.
  3. The 32 bit SAM D21G processor has a whole host of capabilities - ARM Cortex-M0+ based microcontroller with 256KB Flash, 32KB SRAM, 48 MHz, three 16-bit timer/counters, DMA, USB Host and Device, real-time clock, 14 ADC, 10-bit DAC, 21 PWM capable digital pins, 6 UART, 6 I2C, 6 SPI (38 total pins).  Using the Leonardo header pinout, only a small fraction of the chip's power is exposed.  Kind of a waste as posters to forums state they would like to use the whole chip.
  4. Documentation states a target with the potential to realize truly innovative ideas for smart Internet of Things (IoT) devices, wearable technology, high-tech automation, crazy robotics, and projects not yet imagined.  The platform is ill-suited for wearables, and awkward for many IoT applications due to the limited pinout.  Translating this board to a finished product is much harder due to the large, complex chips it uses.  For robotics and automation, this board holds promise but I'd still like full access to all the SAM D pins.
  1. Eventual shield compatibility once the manufacturers gear up new boards.
  2. Much more memory (program and RAM) for more advanced program capability
  3. Much faster (48 MHz) and more efficient (32 bit processor)
  4. Debugging support
Perceived Problems:
  1. Limited by the few exposed pins in the Leonardo/Uno header pinout
  2. Big - the Leo/Uno size makes it harder to use in embedded applications.  If it was meant only for prototyping, more pins should be available.  If a learning tool, the size is fine but the fragility of the processor is of concern.  
  3. Taking lessons from Arduino Due, if the standard libraries are not present in software, porting older programs for use on Zero will be very hard.  One of the strengths of the older architecture is AVR code compatibility.  Arduino team support for ARM code, while well intentioned, has been glacially slow.  The test: will code for modern digital LEDs run on this with only minor issues?  It is such a pervasive use case, one would hope so.
The big variable: Cost
If this board is competitive price-wise with Raspberry Pi ($35) then it can be a winner. Even better would be for it to replace the Uno price of $29.95 and the Uno would drop down to the expected $17.50 or so.

The new debugger will be a welcome step up from the old Processing/Wiring IDE of today.  Atmel makes some very, very good software, modern tools but often more technical than beginners can use.  Hopefully the IDE work will translate to the whole Arduino product range as the fragmentation of versions to support other boards has grown out of hand.

Glimmers of Hope:
The Arduino Leonardo has not been a rather successful board but it set a benchmark for the community to use a form factor and software that has evolved into very good third-party products.  Perhaps this is a similar board - one that by itself will not be particularly successful (but probably more so than Due), but will establish the Atmel SAM processors as the successors to the AVR architecture.  The test will be if third-party companies come up with better boards than the Zero but still be compatible with its features.

As details come out, perhaps some of what I have said will not be necessarily pertinent but I think I have the general direction. On real data, we have little to go on until Maker Faire San Francisco in a couple days. 
Until then you can read the sparse Zero product page and the SAM D 21 Microcontroller information.

Saturday, May 10, 2014

Amazon Student

Amazon Student is a membership program created especially for college students.
Amazon Student members receive six months of FREE Two-Day Shipping with Amazon Prime on eligible purchases and e-mail alerts for discounts and promotions. Discounts and promotions will be e-mailed to your e-mail account or made available on the Amazon Student membership page at
Amazon Student members will automatically continue receiving FREE Two-Day Shipping with Amazon Prime when their free period is over with automatic renewal.  And it costs about half what Prime costs after the free trial period.
To consider joining, go to the Amazon Student pages.

Monday, April 21, 2014

Book Announcement: Getting Started with Trinket

Now you may officially know why I have not posted much in the last few months.  From September through December, I was writing tutorials on as previously discussed.  I was contacted by Maker Media who asked for a book on the Adafruit Trinket microcontroller.  How could I refuse?  So I have been writing and writing some more.  Today Amazon now has it for preorder:

Getting Started with Adafruit Trinket

The price will probably be a bit less than those listed as it will probably be edited down a bit more.

A prerelease hardcopy will be out for Maker Faire New York, September 20 & 21st.

More information and it develops.  Thank you to my viewers for your support of my projects.  Mike

Sunday, December 22, 2013

Intel Arduino Galileo

It's here.  The Intel based Arduino Galileo is finally hitting retailers.  I am fortunate enough to have a Microcenter nearby and they have them at the special price of $69.99 in-store limit 1.  They are currently also at and Mouser Electronics with availability announced by Adafruit.  The box:

The box is not that big, It is a bit longer but shorter than the full Arduino Uno box.  It is a bit deeper as it includes a AC to DC adapter and plug adapters for several countries (Europe, UK, Australia, US):

Looking at the board, it is smaller than the publicity photos make it out to be (always happens I would say):

I am told that retailers do not put rulers in their pictures because buyers ask where their ruler is when they get it - putting a quarter coin in there is even a stretch.

Here are the specs:

Galileo is designed to support shields that operate at either 3.3V or 5V. The core operating voltage of Galileo is 3.3V. However, a jumper on the board enables voltage translation to 5V at the I/O pins. This provides support for 5V Uno shields and is the default behavior. By switching the jumper position, the voltage translation can be disabled to provide 3.3V operation at the I/O pins.
Galileo is also software compatible with the Arduino Software Development Environment (IDE), which makes usability and introduction a snap. In addition to Arduino hardware and software compatibility, the Galileo board has several PC industry standard I/O ports and features to expand native usage and capabilities beyond the Arduino shield ecosystem. A full sized mini-PCI Express slot, 100Mb Ethernet port, Micro-SD slot, RS-232 serial port, USB Host port, USB Client port, and 8MByte NOR flash come standard on the board.
Detail of Intel Architecture Supported Features
The genuine Intel processor and surrounding native I/O capabilities of the Clanton SoC provide for a fully featured offering for both the maker community and students alike. It will also be useful to professional developers who are looking for a simple and cost effective development environment to the more complex Intel® Atom processor and Intel® Core processor-based designs.
  • 400MHz 32-bit Intel® Pentium instruction set architecture (ISA)-compatible processor
  • 16 KBytes on-die L1 cache
  • 512 KBytes of on-die embedded SRAM
  • Simple to program: Single thread, single core, constant speed
  • ACPI compatible CPU sleep states supported
  • An integrated Real Time Clock (RTC), with an optional 3V “coin cell” battery for operation between turn on cycles
  • 10/100 Ethernet connector
  • Full PCI Express mini-card slot, with PCIe 2.0 compliant features
  • Works with half mini-PCIe cards with optional converter plate
  • Provides USB 2.0 Host Port at mini-PCIe connector
  • USB 2.0 Host connector
  • Support up to 128 USB end point devices
  • USB Device connector, used for programming
  • Beyond just a programming port - a fully compliant USB 2.0 Device controller
  • 10-pin Standard JTAG header for debugging
  • Reboot button to reboot the processor
  • Reset button to reset the sketch and any attached shields
  • Storage options:
  • 8 MByte Legacy SPI Flash whose main purpose is to store the firmware (or bootloader) and the latest sketch. Between 256KByte and 512KByte is dedicated for sketch storage. The upload happens automatically from the development PC, so no action is required unless there is an upgrade that is being added to the firmware.
  • Default 512 KByte embedded SRAM, enabled by the firmware by default. No action required to use this feature.
  • Default 256 MByte DRAM, enabled by the firmware by default.
  • Optional micro SD card offers up to 32GByte of storage
  • USB storage works with any USB 2.0 compatible drive
  • 11 KByte EEPROM can be programmed via the EEPROM library.

You can see the PCI-E mini slot on the back.  I am looking to re-purpose a wifi radio from a laptop to test that out.

Comparison with other Boards:

The Galileo is upper left, going clockwise the Adafruit Wave Shield, the Adafrit Motor Shield version 2, and the Arduino Uno R3.  There is not much on shield compatibility, that will have to be part of upcoming experimentation.

What You Will Not Get in the Box

What is not in the box: USB cable (A to micro B), software, any parts or shields, no micro SD card.  There is only an Ikea-like diagram in the lid of the box and a hint to go to

Information You Need to Know

The available resources for getting going with your Galileo as of this post:
I will be posting information on using this board, stay tuned.

Sunday, November 3, 2013

Sensing Switches on an Analog Input, Including Multiple Key Presses

Many microcontroller projects quickly run out of pins when adding functionality.  The methodology used to continue to add functionality is to use expansion chips or share pins.  Many methods implement an approach that will register individual switches.  This article shows a method detecting single or multiple key presses.

One method recently written about at uses a well known method of using one analog pin to register different values for different key presses.

This method is also used on various "LCD Shields" used to add buttons to an LCD display on Arduinos.

While these methods work well, they will not correctly register two buttons pressed at the same time.  For the first picture, if the far right button is pressed, the line is grounded and no further buttons will register.  Same for the second picture with the "RIGTH" button.  The reason is the button shorts out parts of the resistor "ladder".  Again, these work, but only give the lowest value to the analog pin.

For my next project, an alarm, I need to be able to differentiate between pins including multiple "buttons" at the same time.  The following is a schematic of what I will use to differentiate between 3 inputs:

The R4 pullup resistor can be the same as the internal pull-up on microcontrollers like the Arduino, enabled via 
pinMode(analogpin, INPUT_PULLUP); 
pinMode(analogpin, INPUT); 
digitalWrite(analogpin, HIGH);  // set pullup on analog pin while the pin is an input.

On Arduinos like Uno, analogpin can be A0 to A5.  For ATTiny based boards like Adafruit Trinket and Gemma, you must use numbers 1 to 3 for the analog pin (GPIO #2 is A1, GPIO #3 is A3, GPIO #4 is A2).  Note the pullup does change the range of the AnalogRead.  See for more information.

My application uses an Adafruit 5 volt Trinket.  In the schematic, Pin GPIO #3 (Analog 3), already has a 1.5 K ohm pullup to use USB, so no additional resistor is required.

For mapping values, you can read the analog measurement as various switch states are changed (your values may differ depending on resistor changes, pull-up values, etc.  You should take measurements on your own setup):

Switches   Value
Nothing    647
1 closed   397
2 closed   537
3 closed   576
1 and 2    320
1 and 3    342
2 and 3    457
All closed 283 

This works by using changing resistors in parallel along with R4 in series.  So if Switches 1 and 2 are closed, the resistance is (R1*R2)/(R1+R2) + R4.  See Wikipedia for a detailed explanation of resistor combinations.  This is also why the resistor values on the switches must be different - you are looking for unique resistances for each combination.  If you use the same values on the switches, the same analog reading will register for each key press.

The values do not have to be the same as the ones I used.  Avoid too small values to limit current to the analog pin.  Avoid values in the Megohm range as being too close to an open.  Values should not bee to close or too far from each other.  I suggest you wire the circuit up and measure the values - you want probably 10 or more between each registered combination.  The jitter (variability in reads) for me was about 2, so when you compare values you want to check like this:

int jitter = 3;
int readvalue;
int switchone = 397; // from table above for my circuit

readvalue=analogRead(analogpin);  // use your pin number

if(readvalue >= (switchone-jitter) && readvalue <= (seitchone+jitter) ) {
    Serial.println("Switch one is closed");

So for a project where you may have multiple key presses, you can sense them on one analog input by placing switches in parallel with differing resistors.