I have been asked to create an example of using E-blocks to control the Formula AllCode robot via it's Bluetooth API so I thought I would share it here just in case anyone else wants to do this.
To do this I used the following E-blocks setup.
EB006 (PIC Programmer) - 16F1937 chip
EB005 (LCD) - PortB
EB024 (Bluetooth) - PortC - Jumpers B & 1
EB014 (Keypad) - PortD
Firstly I added a few additional functions to our Bluetooth v2 component to simplify the process and resolve a bug we came across. To add this component to your v6 installation simply copy the file to your "Flowcode 6/components" directory.
The first example simply scans for Bluetooth devices and prints the Bluetooth Address and friendly name to a LCD E-block connected to PortB. Send this program to the EB006, switch on the Formula AllCode device you wish to control and write down the address. It should be a 12 digit hexadecimal string similar to 00BA55571F8A – The address of one of the FA units here.
The second example shows you how to connect to a Formula AllCode robot and control it using the built in API. This example will need to be edited with the address found from the scanning program. In this program I use the keypad E-block connected to PortD to drive the Formula AllCode around. Holding 2 or 8 drives the robot backwards or forwards. Holding 4 or 6 turns the robot left or right. Releasing the keypad stops the robot.
Enjoy
