Digital – Analog – Mechanical

Lead Image © mechanik,


As innovative companies consistently push the envelope of progress, antiquated hardware nearly two years old falls by the wayside. We take an old iPad, an Arduino Mega, and various other materials to create an in-dash climate control app.

While deciding what to do with my redundant iPad 2, which warehoused all my videos, music, and pictures and has an active 3G connection to the Internet that provides digital maps for navigating through unfamiliar cities, I had a "eureka" moment. This old, worn out piece of last year's technology would fit perfectly in the dash of my truck as a new audio deck.

After a few quick Internet searches, it became apparently easy to integrate the audio source into the amp with a simple cable; however, why stop there? Next was the pursuit to integrate climate control into the iPad as an app.

Proof of Concept

For my climate control console, I used the following materials:

  • Three small 32-step stepper motors [1] (5V, 1/16 reduction gearing)
  • Two prototype boards
  • A RedBearLab BLE Mini [2]
  • Three L293DNE 600mA dual H-bridge motor drivers [3]
  • One Arduino Mega [4]
  • A bundle of jumpers

The stepper motor has five leads and uses a cogged wheel with electromagnets that "step" the wheel around a set position. By energizing the coils, the motor is driven around 360 degrees. The L293D motor driver has the ability to reverse current smoothly, allowing the motor to be driven clockwise or counterclockwise.

Wiring the stepper motors to the motor driver ICs is the first task. Figure 1 shows the motor wires-to-L293D pin assignments (Figure 2), and Figure 3 shows the motor wired to the driver on a breadboard. As you can see, four of the five wires from the stepper motor are connected to the third pins from each end on both sides of the motor driver (pins 3, 14, 6, 11).

Figure 1: Stepper motor pin assignments to the L293DNE motor driver. (Fritzing)
Figure 2: L293DNE dual H-bridge motor driver and pin assignments to a stepper motor and to the Arduino Mega. (IC: Fritzing)
Figure 3: A stepper motor and L293D motor driver wired on the breadboard. (Fritzing)

Now that the stepper motors are wired to the motor drivers, the next step is to wire the drivers to the Arduino Mega. This process is a bit more cumbersome. Figure 4 shows the Mega with the pin assignments to each of the L293D motor drivers along the bottom.

Figure 4: The Arduino Mega pin assignments to the L293D. (Fritzing)

To power my project, I created a 5V bus strip (power rail) on my breadboard; then, I connected the four corners of the IC (pins 1, 16, 8, 9) with jumper wires and jumpered them back to the 5V bus. Ground was simpler: I created a bus for ground then pulled pin 4 back to the ground bus. The final wiring step was to connect the I/O pinouts from the Arduino Mega (pins 2, 15, 7, 10) back to the L293D motor drivers (Figure 5).

Figure 5: All the wiring for one motor. (Fritzing)

After wiring one stepper motor, I then proceeded to download the Arduino integrated development environment (IDE) for testing.

Arduino IDE

The Arduino IDE is open source software that allows you to write code and upload it to your board. The IDE is available for the three most popular operating systems (OSs): Windows, Mac OS X, and Linux. Installation instructions for your OS can be found online [5].

After installing the software, plug in the USB connector from the Arduino Mega into an open port on your computer. The computer will autodetect the device and associate a driver with the Arduino. To determine whether you have a COM port associated with the Mega, on Windows, right-click Computer | Properties | Device Manager | Ports (COM & LPT). If the Arduino software has installed correctly, you should have a COM port associated with the Arduino device (Figure 6).

Figure 6: Your Arduino device is associated with a COM port.

At this point, you can launch the Arduino IDE. At first, the software loads a blank sketch, and you will have to fix a couple of settings. To begin, click Tools | Board | Arduino Mega 2560 or Mega ADK. Then, click Tools | Serial Port | COM4 (which is the port set by the Device Manager). Once you have fixed these settings, you can test your single stepper motor.

Buy this article as PDF

Express-Checkout as PDF

Pages: 7

Price $2.95
(incl. VAT)

Buy Raspberry Pi Geek

Get it on Google Play

US / Canada

Get it on Google Play

UK / Australia

Related content