Control a servo with your phone using bluetooth! – maker challenge – teachengineering hp gas online registration


In advance: Naming the Bluetooth modules takes a little time, so do this in advance. Alternatively, add an advanced concept to the activity (and ~60 minutes) by having students configure their own Bluetooth modules. Follow the Bluetooth Hookup Guide to give each Bluetooth Mate a unique name and PIN (personal identification number). Without a unique name and PIN code, it can be difficult to discern which Bluetooth Mate is which. Because it is easy to forget, attach to each Mate a small label with its name and PIN. The guide is dense with information; find instructions for naming and setting pins in the Example Code – Using the Command Mode section.

Student kickoff prompt: Have you been able to control a servo with your computer? Great! Now, let’s take that understanding to the next level and control the servo wirelessly! Harald Bluetooth was the legendary Scandinavian King who united Denmark with Norway. Bluetooth—the technology—unites disparate technologies together, such as connecting your cell phone to your car or computer. With a common communication link—Bluetooth—we can use serial communication to control a servo wirelessly.

This maker challenge is all about hooking up the Bluetooth modules. It is strongly recommended that you conduct and/or review the Make and Control a Servo Arm with Your Computer maker challenge before trying this challenge. Students often find that the Bluetooth aspect is relatively simple, while understanding serial is much more difficult!

The first step of this maker challenge is to load the code that controls the servo from the serial monitor on the Arduino from the previous challenge. This code, with a few important tweaks, is all that is needed to “cut the cord” from the servo control project and move to using wireless Bluetooth.

When students have the code running and controlling the servo, the next step is to connect the Bluetooth. The major hang-up on this step is that the TX goes to RX, and RX to TX. It seems a little odd at first, but the key is to think about it like a phone—your voice goes to the speaker—to help it make sense. The Vcc of the Bluetooth is connected to 5V of the Uno, and the ground of the Bluetooth needs to be connected to the ground of the Arduino. The wiring summary follows:

Note: If students attempt to test changing the servo angle using the serial monitor from their Arduino applications after modifying the code, they need to change the baud rate on the drop down menu in the serial monitor from 9600 to 115200 as well.

BUT, if you try to upload this code with the Bluetooth attached to the Arduino pins RX and TX, the code will not upload! This is because serial communication over these pins conflicts with the serial communication from the board to the computer. To upload the sketch with the changes, the easiest solution is to unplug the TX and RX pins just before an upload and then plug them back in when the upload is complete. The code is shown in Figure 1.

• Pair the device. On some phones, this step must be performed twice for the phone to pair. Make sure to have the PIN codes handy (the default for most Bluetooth Mates is “1234”) > turn ON the power for both devices > search for the module in the Android “Settings” app under Bluetooth > unplug the Uno from the computer > plug the Uno into the 9V battery/adapter.

As a class, have students reflect on what worked and what was challenging about the activity. Did the code work right away? What were the challenges experienced while migrating from a wired to a wireless connection? If you did this activity again, what would you change?