Today’s example is continuing to build on our previous robot examples but this time integrating Bluetooth and an Android device. The Bluetooth is similar to our earlier Bluetooth-Android example. In this example we are using a free android app, a Bluetooth module, and the Pioneer kit to control a robot’s movement:
- PSoC 4 Pioneer Kit
- Seeedstudio Motor Shield
- Two motors and Robot Chassis
- 9V battery Pack
Forum Post Attachments:
At the bottom of this post we are including the following items:
- Example Project Zip File
- Zip File of Images
- Project Schematic
- Component Configurations
The user can download the example project at the bottom of this post. The project uses the following list of Creator Components:
- Control Register
The components are configured by right clicking on the component in your Top Design schematic view and selecting Configure. Please enable the following selections in the Configuration windows for the listed components above.
The main.c firmware is included in the example project. Please review the commented sections for more details.
This project contains a UART module to receive the commands from the Bluetooth module. Each command packet consists of 7 bytes. The structure is described in our Struct “BT_CMD_S”. Since we will be binding to the Android device and using the 4Joy app, we will support the following commands:
- Turn Left
- Turn Right
- Increase Speed
- Decrease Speed
For turning left or right Motor-B is used. For moving forward or reverse Motor-A is used. A control register is used to control the direction of the motor and a PWM signal is used to control the speed.
The user will need to download the 4Joy app (linked above). Once the app is downloaded you will be able to pare to the Bluetooth device. You will need to have the Pioneer board programmed and powered prior to paring to the Bluetooth device. First make sure that Bluetooth is enabled on your device. The open the App and click the ‘Connect’ button. You will be able to scan the available Bluetooth devices for paring. Select the ‘Linvor’ option from the menu. When the device is connected you will be able to begin to control your robot using the Android device. Use the buttons on the app screen to see the robot respond to your commands.
Connect your Seeedstudio motor shield to the Pioneer kit. Insert the Bluetooth module into the header on the Seeedstudio kit. Please see the image below for the setup.
You will then need to wire up the robot motors to the Seeedstudio motor shield and connect the power to the kit.
Test Your Project:
Program your Pioneer board and then connect the power. Then bind your Android device to the Bluetooth module. Then use the 4Joy Remote Controller app to drive your robot around. We will be putting together a video of this robot and will post it in the comments below.
I hope this example can help you in your design.