Make: Getting Started with Adafruit Trinket: 15 Projects with the Low-Cost AVR ATtiny85 Board
Format: PDF / Kindle (mobi) / ePub
Arduino's ubiquity and simplicity has led to a gigantic surge in the use of microcontrollers to build programmable electronics project. Despite the low cost of Arduino, you're still committing about $30 worth of hardware every time you build a project that has an Arduino inside. This is where Adafruit's Trinket comes in. Arduino-compatible, one-third the price, and low-power, the Trinket lets you make inexpensive and powerful programmable electronic projects. Written by one of the authors of Adafruit's Trinket documentation, Getting Started with Trinket gets you up and running quickly with this board, and gives you some great projects to inspire your own creations.
(see “ATtiny-Optimized Libraries” for library locations and “Installing Libraries” for instructions on installing libraries): TinyWireM library (for I2C communication) TinyLiquidCrystal library TinyDHT library The TinyLiquidCrystal library is the Adafruit LiquidCrystal library with additional support for one of the display driver chips, along with use of TinyWireM instead of the Wire library. The TinyDHT library is special. The Adafruit DHT library uses floating-point (decimal) math, which
speaker as an output, you won’t hear a sound! The servo position is changed every loop, but it’s only activated if you’re petting the animal. Read the photocell. If the light level is below a certain value, something is blocking it; this is how we determine the animal is being petted. This toggles a pin to play a tone on a piezo speaker. This routine refreshes the servo every 20 milliseconds as required. Preparing the Toy The animal I chose is a classic Beanie Baby toy. The code makes a
more uses for it every week. So should the Trinket be recommend the Trinket for all projects? Absolutely not. The Trinket is perfect where it will work effectively: in small-size, low-power projects. For projects requiring additional speed, memory, or digital pins, there are other microcontrollers to consider. Changing platforms often comes at a cost, though: the Trinket is inexpensive compared to other controllers with better hardware. For a hobbyist or manufacturer, cost is often an issue. So
for your Trinket projects. Troubleshooting: Check your connections and USB port to make sure that everything connects well. If there is a problem, try swapping the cable for a thicker, more substantial one, or consider purchasing a new one. As a final check, disconnect the USB cable and connect the Trinket to external power. Connect 3.7 to 9 volts, with the positive to the BAT+ pin and negative to the GND pin. If the green LED glows and you have a dim red LED for 1–2 seconds, your Trinket is
__AVR_ATmega32U4__: Leonardo, Flora, Micro, Esplora __AVR_ATmega2560__: Mega 2560 Note that __AVR_ATtinyX5__ does not work; you need to replace the X with an 8. You might think the following code could work: #ifdef __AVR_ATtiny85__ #include