The Arduino Inventor's Guide (39 page)

BOOK: The Arduino Inventor's Guide
12.2Mb size Format: txt, pdf, ePub

FIGURE 7-30:
The fan-motor box

FIGURE 7-31:
Completely assembled motor box with the motor inside

FIGURE 7-32:
Final fan blade

This will ensure that the fan doesn’t hit the plant or anything else inside the tiny greenhouse. Using a small dab of hot glue, attach the fan blade to the motor as shown in
Figures 7-33
and
7-34
.

FIGURE 7-33:
Securing the fan blade to the motor

FIGURE 7-34:
Fan-motor assembly complete

Connect It Up

Now you have all of the pieces you need for your Tiny Desktop Greenhouse, so it’s time to install the electronics. Remove the temperature sensor from the breadboard, and use three male-to-female jumper wires to extend the connections of the sensor, as shown in
Figure 7-35
. Pay attention to which wires you move, and connect
them up again using the extended wires. When you hold the flat side of the temperature sensor facing you with the pins to the left, the top pin is power, the middle pin is the signal, and the bottom pin is ground. We used red, yellow, and black wires to show the power, signal, and ground connections, respectively.

FIGURE 7-35:
Extending the temperature sensor with male-to-female jumper wires

You’ll need to place the temperature sensor inside the greenhouse. Use a piece of masking tape to secure the temperature sensor directly to the plant before sticking it inside your new greenhouse, as shown in
Figure 7-36
. You can now feed the wires out under one side of the greenhouse, or you could also make a small hole to feed the wires through.

FIGURE 7-36:
Secure the temperature sensor directly to your plant

Similarly, move the fan-motor assembly so that it sits near the corner of the greenhouse. The motor wires should be long enough to reach the breadboard without extensions, but if you need to, you can add extra male-to-female extension wires to make wiring easier.

Now, you should still have enough room for a small plant to rest comfortably in this new cozy habitat. It’s time to get your new exotic house plant and put it inside your brand new greenhouse! To test out how effectively our autovent system regulated the temperature, we created our own indoor sun with some really big floodlights to heat the air.

Figure 7-37
shows one of our tests on the Tiny Desktop Greenhouse.

FIGURE 7-37:
Testing a Tiny Desktop Greenhouse

GOING FURTHER

There are a lot of opportunities to take this project to the next level.

Hack

At the moment, your greenhouse is pretty darn small. To make space for more plants, find a large cardboard box like the ones used for copy paper. Cut some windows in it, line them with transparency film, and move the electronics into this bigger and better greenhouse. Or, take a look at the plastic greenhouses they have over at IKEA. Where can you mount the servo motor so that you can open and close the window on this greenhouse?

Modify

The current set point is 85 degrees Fahrenheit, and although that was a good temperature for us to test because we could easily increase it with our own body heat, it’s actually still pretty low for most plants. Look up the ideal growing temperature for your plant, and modify your code to use this new set point.

You can also modify how often the greenhouse samples the temperature with the delay. A delay of 1 second is pretty short. If your temperatures swing at all, the lid will be opening and closing every few seconds. This can quickly become annoying. Change this delay to something like 5 minutes, which would be 30,000 ms.

8
Drawbot, The Robotic Artist

As an homage to the Logo turtle project, in this project we’re going to make a Drawbot: a robot that you can program to move and draw. Logo was a programming language created in the late 1960s by Daniel G. Bobrow, Wally Feurzeig, Seymour Papert, and Cynthia Solomon. It was later adapted to support a robot with a drawing pen called a
turtle
(see
Figure 8-1
).

FIGURE 8-1:
An early version of a Logo turtle

Turtles were connected to a computer to receive movement commands in the Logo language, such as
fd 10
to drive forward 10 spaces. As the turtle moved, it drew with the attached pen. These Logo turtles were an early educational system designed to teach programming concepts in a visual way.

You’re going to build your own Arduino-controlled turtle, the Drawbot (
Figure 8-2
), which was inspired by the work of Seymour Papert and his team.

FIGURE 8-2:
A completed Drawbot

MATERIALS TO GATHER

Your robot will have two wheels, each with a motor that’s controlled by the Arduino through a new component called an
H-bridge
. An H-bridge is a small modular circuit board similar to the transistor circuit you used in the last project, except that it will enable you to
control both the speed and the direction of the motor. This will give your robot the most flexibility and control. Gather your parts (shown in
Figures 8-3
and
8-4
), and let’s get started!

Electronic Parts

• One SparkFun RedBoard (DEV-13975), Arduino Uno (DEV-11021), or any other Arduino-compatible board

• One USB Mini-B cable (CAB-11301 or your board’s USB cable)

• One solderless breadboard (PRT-12002)

• Two geared hobby motors (ROB-13302*)

• One TB6612FNG H-bridge motor driver (ROB-09457* unsoldered or ROB-13845* presoldered)

• Two rubber wheels fit for the geared hobby motors (ROB-13259*)

• Male-to-male jumper wires (PRT-11026)

• Male-to-female jumper wires (PRT-09140*)

• One 4 AA battery holder (PRT-09835*)

NOTE

The parts marked with an asterisk (*) do not come with the standard SparkFun Inventor’s Kit but are available in the separate add-on kit.

FIGURE 8-3:
Components and materials for the Drawbot

Other Materials and Tools

• Pencil

• Craft knife

• Metal ruler

• Glue (hot glue gun or craft glue)

• (Optional) Drill and 3/16-inch drill bit

• (Optional) Soldering iron

• Cardboard (about 12 inches square) or a cardboard box

• Ping-pong ball

• Enclosure template (see
Figure 8-12
on page
235
)

FIGURE 8-4:
Recommended tools

NEW COMPONENTS

You’ll be using two new components in this project: an H-bridge motor driver and geared hobby motors. Let’s take a look at how these components work.

The H-Bridge Motor Driver Integrated Circuit

In
Project 7
, you used a transistor circuit to control a single motor with Arduino, which allowed you to control the speed of the motor but not the direction of its spin. In this project, you’ll use a new component called an
H-bridge motor driver
that will allow you to control both the speed and direction of the motor.

The H-bridge motor driver is an integrated circuit (IC) chip, made up of about a dozen transistors wired together internally inside a small plastic package. An
IC chip
is a prewired circuit that has been integrated into a single package to make building complex projects easier. There are many different ICs out there; one example is the brain behind the Arduino Uno, the ATMega328 chip. In this case, the H-bridge motor driver IC allows you to control a motor’s speed and direction of rotation by connecting power and just a few signal wires to the Arduino.

You might recall from
Project 7
that a transistor is simply a switch that can be controlled electronically. A standard H-bridge motor driver consists of four or five transistors (or switches) wired up in an H configuration, as shown in
Figure 8-5
. (The motor shown in the middle isn’t included in the H-bridge IC; you’ll add that in.) By controlling which of the four main switches (labeled A–D) are open or closed, you can control the direction in which the current flows through the motor. The fifth switch (E) controls the speed of the motor’s rotation.

FIGURE 8-5:
H-bridge circuit for both direction and speed control

Remember that current flows from positive to negative. If you closed switches A and D, current would flow through the motor from left to right, turning the motor in one direction. If you instead closed switches B and C, current would flow through the motor from right to left, causing it to spin in the opposite direction.

Switch E is pulsed on and off rapidly through PWM (see “
Create Analog Signals with PWM
” on page
139
). The duty cycle of this PWM signal will determine how fast the motor spins. On your robot, you’ll have two motors, each with its own H-bridge circuit, and you’ll attach a wheel to each motor so you can control its spin speed and direction.

The H-bridge motor driver you’ll use in this project is the Toshiba TB6612FNG, shown in
Figure 8-6
. It comes as a breakout board with holes for pins that are spaced 0.100 inches apart—perfect for inserting into a breadboard.

FIGURE 8-6:
TB6612FNG H-bridge motor driver breakout board (without pins soldered)

NOTE

The chip also has a standby pin that can be used to put the motor in standby mode to conserve power, but you won’t need this feature, so you’ll disable it.

The Toshiba TB6612FNG is actually a
dual
H-bridge IC. This means it has two full H-bridge circuits built into a little package, allowing you to control the two motors on your robot with a single board. The H-bridge distinguishes the two motors as A and B, as you can see on the underside of the board in
Figure 8-6
. To control each H-bridge circuit, you use three signal wires: two for direction and one for speed.

You can buy the board either with or without pins already soldered on, so if you want to save yourself the trouble of soldering, make sure you get the presoldered board (ROB-13845). If you have the board without header pins already soldered on (ROB-09457), it’s not a problem, but you’ll need to solder male headers onto the pins; for soldering instructions, see “
How to Solder
” on page
302
. In either case, before you start building this project you should have a board that looks like
Figure 8-7
.

FIGURE 8-7:
DEV-12211 H-bridge motor driver with headers soldered on

Geared Hobby Motor

The basic hobby motor that we used in
Project 7
is great for simple mechanisms like spinning fans, but it doesn’t offer a lot of
torque
(rotational force). In this project, we want to use a motor to move the entire project around, so we need to use a
geared motor
—a motor that’s attached to a
gearbox
(see
Figure 8-8
).

Other books

Catch a Rising Star by Tracey Bateman
Bones Are Forever by Kathy Reichs
Summer Lightning by Cynthia Bailey Pratt
The Scar by China Mieville
Secret Fire by Johanna Lindsey
Sing Me Your Scars (Apex Voices Book 3) by Damien Angelica Walters
The Crisis by David Poyer