Table of Contents
Foreword ix
Preface xi
1 Introducing Trinket 1
Trinket Versus Arduino Uno 2
Using Trinket 3
The ATtiny85 Microcontroller 3
Memory 4
Connectivity 5
Three Volts or Five Volts? 7
The Adafruit Gemma 8
2 Software Installation 9
Supported Operating Systems 10
The Preconfigured Arduino IDE from Adafruit 10
Modifying the Standard Arduino IDE 11
The USBtinyISP Driver for Windows 11
Seeing the Trinket in Windows 14
Windows Driver Troubleshooting 15
Linux 15
Conclusion 15
3 Connection and Programming 17
Preparing the Trinket 17
Connecting Trinket to Your Computer 19
Loading a Program 21
The Trinket Data Pins 24
Digital Pins 24
Analog Pins 25
Exploring Data Pins 25
Parts List 25
Connections 26
Not All Pins Are the Same 26
Different Ways to Power Trinket 28
Analog and Digital Sensors 30
Trinket Theremin 30
Parts List 30
Wiring 32
Code 32
Use 34
Sound and Music 34
Conclusion 35
4 Libraries and Optimization 37
Arduino Libraries 37
ATtiny-Optimized Libraries 39
Installing Libraries 41
Where to Install Libraries 42
Installing a Library in Windows 44
Installing a Library in OS X 47
Using Libraries 49
Library Issues and Limitations 50
Memory Optimizations 50
Program Space Optimization 51
Variable Optimization 51
Conclusion 53
5 Intermediate Projects 55
Controlling Smart LEDs: NeoPixels 55
Important Things to Know About NeoPixels 56
NeoPixel Packaging 57
NeoPixel Ornaments 57
Parts List 58
Build 58
LED Color Organ 61
How It Works 62
Parts List 62
Build 63
Adjustments 67
Mounting 67
Kaleidoscope Goggles 68
Parts List 69
Tools 69
Battery Selection 70
Wiring 70
Software 73
Final Assembly and Use 75
Safety and Common Sense 77
Servos 78
Inside a Servo 79
Trinket Servo Control 60
Parts List 81
Wiring 81
Code 82
Use 83
Going Further 83
Using I2C-The Two-Wire Interface 84
I2C Software 85
Using I2C Displays 85
Temperature and Humidity Sensing 86
Parts List 87
Libraries 88
The LCD Display 88
Testing the Display 90
Adjustment 91
Sensing 91
Code 93
How It Works 94
Troubleshooting 95
Going Further 95
Ultrasonic Rangefinding 96
Parts List 97
Build 97
Libraries 99
Code 99
How It Works 102
Troubleshooting 102
Communicating via Serial 102
Talking Serial 104
Exploring Serial Use 104
Parts List 104
Code 105
Use 106
Going Further 108
Pulse Width Modulation 108
The Analog Meter Clock 110
Circuit Design 111
Parts List 111
Build 112
Meters 112
Libraries 13
Code 113
How It Works 115
Preparing Your Meters 116
Meter Mounting 117
Conclusion 119
6 Advanced Projects 121
Trinket Jewelry 121
Parts List 122
Choices 122
Tools 123
Wiring 123
Libraries 124
Code 125
Animation 128
Compile 131
Changing the Animation 132
Finishing the Jewelry 133
Program Memory for Data 134
Trinket Occupancy Display 135
Parts List 136
Tools 137
Wiring 137
Libraries 139
Code 139
Enclosure and Board 141
Box Connections 142
Adjustment 143
Room Placement 145
Going Further 145
Trinket Alarm System 146
Parts List 147
Tools 147
Theory 148
Multiple Sensors, One Pin 149
Project Design 151
Annunciation Selections 152
Build 153
Populating the Board 154
Code 157
Final Assembly 160
Test 161
Troubleshooting 163
Going Further 163
Bluetooth Communication 164
Trinket Toy Animal 165
Choosing Your Animal 165
Parts List 186
Tools 167
Circuit 167
Circuit Variations 168
Code 169
Preparing the Toy 171
Use 173
Trinket Rover Robot 173
Parts List 176
Tools 175
3D Printing 176
Build 176
Wiring 179
Code 181
Going Further 183
SPI Communications 183
Trinket Audio Player 185
Parts List 186
Tools 187
Software 188
Loading Sounds 188
Chip Loading Circuit 139
Transferring Audio 192
Sound Playback 193
Use 197
Conclusion 197
7 Going Further with Trinket 199
Microcontrollers: Smaller Versus Larger 199
The Trinket Bootloader 200
The Bootloader Design 201
Bootloader Code 201
Repairing the Trinket Bootloader 202
Programming Bare ATtiny85 Chips 203
Other AVR Programming Methods 205
Community Resources 206
Learning Arduino 207
Commercial Resources 207
Technical Resources 208
Third-Party Sites 208
Social Media Resources 209
8 Troubleshooting 211
Your USB Cable 211
Connectivity Issues 212
Arduino IDE Issues 215
Mac 215
Common Library Problems 217
Error Messages 219
Compilation Issues 219
Upload Errors 221
The Serial Monitor 222
Usage Issues 222
Manufacturer Support 224
A Making Electronic Sounds 225
B Parts Sourcing 231
C Publications 235
Index 237