Introduction: Use Xbees (series 2) to Control a Motor
Note: I used the xbee I linked to, but for a one to one communication, rather than a network of wireless devices, xbee series 1 would do fine, but the AT commands are slightly different.
This instructables was made at TechShop! www.techshop.ws
You can also control servo motors, or make a moving wireless security camera, as seen below.
In the photos I'm actually using an seeeduino but it is very similar to Arduino
Step 1: Materials
Step 2: Set the Firmware on the Xbees
1.On a PC, download X-CTU
2.With the first Xbee plugged into the Xbee Explorer, and the usb cable connecting it to the computer's USB port, Open up X-CTU.
Click "Modem Configuration"
Click "READ" in the top left.
3.Set the first Xbee (the one currently plugged in) as ZIGBEE COORDINATOR AT (see the top)
4. Set the Pan ID to be a unique one (I used 1234)
5.Then, make note of the SH and SL
The SL is unique for each xbee. A great practice is to LABEL on that xbee the SL so you always know its address.
6.Then, set the DH and DL of that xbee to the SH and SL, respectively, to the xbee it is going to be talking to and listening to.
(the SH and SL can be found on the BACK of the XBEE on the white label)
7. Click WRITE.
8. Once it is finished, (see the bottom of the monitor), remove it and place the other xbee in the xbee explorer. You can unplug and replug the USB but you don't have to.
9. Click READ again in the top left of the X CTU window.
10. Set this Xbee to be ZIGBEE END DEVICE AT.
11. Set it's PAN ID to be the same UNIQUE PAN ID of the other xbee (1234 in my case)
12.Set the DH and DL to be the SH and SL of the OTHER Xbee that you previously updated.
13. Press WRITE and wait for the firmware to be updated.
You're xbees should talk now!
If you had a second xbee explorer and another computer, you can hook both xbees up, and in X CTU go to "TERMINAL".
Whatever you type in one terminal window should show up in the other computer's XCTU terminal window.
Step 3: Wire the Motor
I used the sn754410 H-bridge. To wire it to arduino, follow the following schematic in the fritzing drawing.
The H bridge has the following pins and functions: The H-bridge has the following pins and features:
Pin 1 (1,2EN) enables and disables our motor whether it is give HIGH or LOW
Pin 2 (1A) is a logic pin for our motor (input is either HIGH or LOW)
Pin 3 (1Y) is for one of the motor terminals
Pin 4-5 are for ground
Pin 6 (2Y) is for the other motor terminal
Pin 7 (2A) is a logic pin for our motor (input is either HIGH or LOW)
Pin 8 (VCC2) is the power supply for our motor, this should be given the rated voltage of your motor
Pin 9-11 are unconnected as you are only using one motor in this lab
Pin 12-13 are for ground
Pin 14-15 are unconnected
Pin 16 (VCC1) is connected to 5V
See here for more info.
(Also, before wiring the motor, I took off the top so i could look at the gear box - the gears look super cool...see the images)
Step 4: Upload the Code
Now, you can adjust the direction of the DC motor by pressing 'a' and 's' in the serial monitor of Arduino.
If you are using servos like I was in the video with three servos mounted to a wireless webcam, you can use this code instead:
Step 5: Connect the Xbee to the Arduino.
Leave one xbee connected to the computer via the Xbee Explorer and the USB. The other xbee needs four connections: power (3.3 V), ground, tx, and rx.
See the pinout in the image : the pins you have to wire are:
xbee pin 1: to Arduino's 3.3V
xbee pin 2: to Arduino Rx (digital pin 0)
xbee pin 3: to Arduino Tx (digital pin 1)
xbee pin 10: to Arduino ground
You can also get an xbee shield like this.
Step 6: Talk to Arduino From Xbee
With one xbee plugged via USB to the PC, open X-CTU TERMINAL tab.
Now, you can have a standalone motorized device: With the other Arduino unit that you just programmed and wired up, unplug itfrom the computer USB. Plug in a battery either to the DC jack (9-12 V battery works well) or Voltage into the Vin pin and ground into the Arduino's ground.
Now, if you type 'a' into the terminal, the motor (hooked up to the standalone Arduino / Xbee battery-powered unit) should begin to spin one way.
if you type 's' into the terminal, the motor will spin the other direction.
Great! You have a wirelessly controlled motor.
Now make a r/c robot!