Hardware Reference
In-Depth Information
Given these features, it is possible to program the ATtiny using an Arduino by configuring an Arduino Uno or
another board with the Arduino ISP sketch and wiring the boards to each other, which I will demonstrate in the
following example.
Project: Secret Knock Box
In this example, you will use a secret-knock example to open a small box with a servo. The idea is to detect a knock
and then trigger a servo to open the box. Then you can then use a double-knock to close the box. The box remains
closed until the secret knock is identified. This technique has been used to open doors and boxes and to trigger events
based on a knock code. I used them in my Morse's Secret Box project, where tapping Morse code opened the box. The
laser-cut designs for these boxes can be found online at http://github.com/ricklon/morsessecret . A custom circuit
board for the project, called the ATtiny Servo, is available as well, at https://github.com/ricklon/attinyservo .
This project is typically done with a larger chip or a standard Arduino Uno. However if you were to make 20, 30, or
even a thousand of these boxes the cost and complexity would be very high. This makes it impractical to sell a project
for a profit, or efficiently reduce the complexity of project. It is a good idea to prototype on an Arduino Uno which
on average costs $35.00 per unit. In this case, though, you want to use the ATtiny85, which costs around $1.29, or
approximately $0.75 in quantities of 25.
The options for this chip are somewhat limited, so if Servo.h is unavailable, there are other servo options available.
However, because there is only one timer on the chip, there is a conflict with the Arduino standard Servo Library.
Other servo options are available, but the very basic option is to operate the servo manually by programming the chip
to send the servo pulse commands. This solution works well, and is modeled by this project.
This chapter introduces a project that uses a knock sensor to tap a secret code. LEDs are used to show a knock
occurred, and was detected. When the correct code is sensed a command is sent to move a servo to open a box lid.
An ATtiny85 is used because it has a small form factor, and the additional electronics can fit in extremely small spaces.
What the Device Does
When you program a knock pattern into the device, the system listens for the knock, and the servo is triggered to open
the box. Additionally, there is a programming mode where you can set the knock and use some LEDs for feedback on
the programming process. This project transforms the code from just a stand alone sketch to a library that can be used
in many projects.
Bill of Materials
For this project, you will need the following:
Servo
Piezo
Two LEDs
One button
Two resistors (220k
W)
One 6M
W resistor
The project is small enough to be a simple do-it-yourself PCB or a breadboard, as in Figure 9-9 ; it can also use
dead bug-style wiring.
 
Search WWH ::




Custom Search