Software apps and online services
In this project we will be adding BLE + Firmata to control a LaunchPad remotely. We can demonstrate this functionality with the LaunchPad itself, as well as adding the LaunchPad to the DFRobot Cherokey kit to showcase how it can be used in simple robotics. RedBearLab has a sample app for Android 4.3+ and iOS that we will be using as our test platform, so no android or iOS app programming is necessary for this project.HardwareTI LaunchPad
LaunchPads are microcontroller development kits from Texas Instruments. There are many different varieties but this example will work for any that support Energia. We are using an MSP430 LaunchPad.
The BLE mini is a small development board that features TI's CC2540 BLE module. It utilizes simple UART communication with a host microcontroller (MCU). The Cherokey kit from DFRobot is a slick package that includes the chassis, motors, wheels, and some on board electronics to make getting started with the vehicle easier and affordable.
You can find if it you search around Amazon or Google.SoftwareEnergia IDE
We will use the Energia IDE to program the LaunchPad. You can download the latest version at here.Firmata
The example uses Firmata which is an open source protocol project that allows you to dynamically control a microcontroller with UART. This could be through a PC or with BLE. https://github.com/firmataTesting Firmata
Let's do something simple like control our LEDs on the LaunchPad with BLE. This will help us set up our basic system so that we can build the BLE Racer later.
Hook the RX line of the BLE mini to the TX line of the LaunchPad, and hook the TX line of the BLE mini to teh RX line of the LaunchPad. Attach Vin and GND of the BLE Mini to VCC and GND of the LaunchPad. That's all we need for the hardware part. On your Phone or tablet, download the BLE Controller app from RedBearLab on App Store or Google Play.
Open up Energia and upload the RBL_BLEMINI firmware. On the Phone:
1. Turn on your Bluetooth
2. Launch the Red Bear BLE Controller App (Make sure you are in BLE Controller Mode, swipe right or use the menu to find different modes)
3. Swipe down to scan for devices if none show up.
4. The device is called "Biscuit" by default, click it to connect, you should see a list of numbers populate. These correspond to the pins.
5. Go down to 43 (our Red LED pin on the MSP430F5529 LaunchPad) and set it to OUTPUT. They are set to INPUT by default. If you are using a different LaunchPad just go to the right LED pin. You can find out the pin number for your LEDs on www.energia.nu/pinmaps.
6. Turn 43 to HIGH and you should see the LED come on. Turn it to LOW and you should see the LED go off.
Congratuations! You know have full remote control over your LaunchPad thanks to Firmata.Instructions for BLE Racer
Software download for mobile:
- If you have iPhone, you can get it directly from the App Store.
- If you have Android, you will need 4.3 or higher in order to have your BLE supported by the Android OS. They have the app on Google Play. If you have trouble, you can also download the .apk from their website directly.
On the car:
- Insert 5x AA Batteries on the bottom.
- Turn on the switch in the back of the racer, LEDs should turn on, that’s all you need on the car side. If it doesn’t turn on, check your batteries on the bottom.
On the phone:
- Turn on your Bluetooth.
- Launch the Red Bear BLE Controller App (make sure you are in BLE Controller Mode, swipe right or use the menu to find different modes).
- Swipe down to scan for devices if none show up.
- The device is called "Biscuit" by default, click it to connect, you should see a list of numbers populate. These correspond to the pins.
- Go down to 37 – 40 and set everything to OUTPUT. They are set to INPUT by default. Orient the phone to landscape for a more comfortable driving position.
- To go forward, set pins 37 & 40 to HIGH and then set 38 & 39 to HIGH to actually move the car.
- To Stop, make sure pins 38 & 39 are set to LOW.
- To go backward, set pins 37 & 40 to LOW and then set 38 & 39 to HIGH to actually move the car.
- To Turn you just set 38 HIGH and 39 LOW or 38 LOW and 39 HIGH.
You can practice to get the hang of it.Explanation of the Demo
We have a robot vehicle, the DFRobot Cherokey kit ($50), with an on-board motor driver connected to and MSP430F5529 LaunchPad ($13) via PWM pins. The LaunchPad is also connected to a CC2540 BLE Module made by Red Bear Labs called BLE Mini ($30) and is just communicating via UART - RX and TX pins + VCC and GND, very simple. The phone app is featuring a software framework called Firmata, which lets us dynamically populate a list of every single pin on the LaunchPad and we can set each to either an input, output, or PWM signal to rapidly prototype and test our hardware for function, with the added bonus of having it done wirelessly. So we are able to put those elements together to create a Bluetooth Low Energy enabled embedded system with off the shelf components.How to build the BLE Racer
Assemble the Cherokey kit using the instructions. You will need to solder on wires for the motors. Recommend using red and black or red and white combo for each motor. Since there are screw terminals on the Cherokey, you should use male jumper wires, so you can fit them into the screw terminals.
Next we need to hookup our LaunchPad and BLE Mini. You can get creative with mounting both boards since there are many attachment points on the Cherokey. You can tape, glue, or solder different ways to keep the vehicle clean and sturdy.