current at will be high enough to be seen as a digital high.
The interrupt routine would simply turn off the output
transistor’s base current to shut things down. Nothing was
done with this, though, to keep things nice and simple.
The Arduino Pro Mini has a reset pin on the printed
circuit board (PCB). This was tied into a momentary N/O
pushbutton switch that can be pressed to reset the system.
This is used after the system has detected something with
one of the three sensors and is now indicating which
sensor caused the alarm using one of the three LEDs. The
RST line on the board needs to be pulled to ground briefly
to reset the microcontroller. The physical connection to this
option was very convenient since the RST and GND pins
are side by side.
The code is very straightforward for this project. The
hardest thing in this project is in the multiple ultrasonic
sensor readings. However, this was made simple by using
an Arduino library called NewPing by Tim Eckel
A setup routine configures the hardware such that the
correct pins are inputs and outputs. The ultrasonic sensors
are then pinged one after another in the main loop. Once a
new set of measurement data has been collected, the
pingDataComplete function allows us to determine if any of
the sensors fall within the alarm zone. If one does, we
sound the alarm to scare off the cat and turn on the
indication LED which corresponds to the sensor that
caused the alarm. If all of the readings are normal, we just
move on and take another round of readings.
During the alarm phase, we move the servo motor
back and forth. Normally, you would code a PWM out to
the servo so that it moved to the desired position. Another
Arduino library has made this very simple. The servo library
( http://arduino.cc/en/reference/servo) lets you take full
control of the servo with just a few lines of code.
Programming with some of these powerful libraries feels a
bit like cheating if you are used to doing things the hard
way, but I will take all the help I can get to speed up
Building the Proto Board
I struggled with the decision to breadboard the circuit
first or just move to a perfboard since it was so simple. I
have been bit by that in the past, so I ended up
breadboarding the circuit first to true everything out.
When making the permanent perfboard version, 0.1 inch
breakaway headers were used to allow the entire thing to
be modular. Of course, this can easily let out the magic
smoke if a cable is plugged in backwards or into the wrong
place. However, the benefits are ease of assembly and any
troubleshooting that may be necessary.
Point to point wiring was used to connect everything
together on the back of the perfboard. Many of the
headers were placed such that they just needed to be
linked to adjacent pins, reducing the chances of any shorts
from crossing wires.
Designing and Building
As mentioned before, the triangular housing
requirement meant it would need to be custom. Thankfully,
the days of cutting plywood using a table saw for project
boxes is over. A small CNC machine and laser cutter are
now options. I opted on using the laser cutter since it is
more precise, less messy, and would create something that
would be strong enough for this build.
Initially, I was thinking of using 3 mm black acrylic for
the design. The intersections of the three faces would be
linked together using some shallow finger joints (just to
keep the edges aligned), and a top and bottom section
40 July 2014