Hello,
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
FA Remote Control From E-blocks EB006 + EB024
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
FA Remote Control From E-blocks EB006 + EB024
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
-
- Posts: 4
- Joined: Tue May 02, 2017 9:57 pm
- Has thanked: 1 time
- Been thanked: 2 times
Re: FA Remote Control From E-blocks EB006 + EB024
I have the exact same setup and managed to connect and control my FAC using your scripts. Now I am required to read a light value from the LDR on the FAC and set it as a variable. I send the script "Readlight" to the FAC but I can't seem to use the returned value as a variable. This has troubled me all day... Could you please help?
-
- Posts: 4
- Joined: Tue May 02, 2017 9:57 pm
- Has thanked: 1 time
- Been thanked: 2 times
Re: FA Remote Control From E-blocks EB006 + EB024
We have been tasked to control the Formula allcode (API mode) via a combination of the EB006 Programmer and a bluetooth card (EB024). When the LDR detects a laser ( Value of +/-3400 ), the buggy should be immobilised for a set time. To do this we need to return a value and attach it to a variable which then could be added to the logic in our program. We have tried various ways of getting this value back to the EB006 but had no luck. Could anyone assist us in this matter?
- Benj
- Matrix Staff
- Posts: 15312
- Joined: Mon Oct 16, 2006 10:48 am
- Location: Matrix TS Ltd
- Has thanked: 4803 times
- Been thanked: 4314 times
- Contact:
Re: FA Remote Control From E-blocks EB006 + EB024
The ReadString function will require you to use a string variable to store the incoming value from the AllCode robot.
The StringToInt$() command will allow you to convert the string variable to a numeric binary value.
The attached example program shows what I mean.
Also please note that the command to read the light sensor should be “ReadLight” and not “ReadLDR”.
The easiest way to fire the laser might be to use one of the LED outputs.
You can control the LED output state using the API commands.
You will need an NPN transistor to amplify the voltage from 3V3 to 5V but this will also provide you with more current to drive the laser. Don’t forget the NPN series base resistor, 1K should be fine.
Hope this helps.
The StringToInt$() command will allow you to convert the string variable to a numeric binary value.
The attached example program shows what I mean.
Also please note that the command to read the light sensor should be “ReadLight” and not “ReadLDR”.
The easiest way to fire the laser might be to use one of the LED outputs.
You can control the LED output state using the API commands.
You will need an NPN transistor to amplify the voltage from 3V3 to 5V but this will also provide you with more current to drive the laser. Don’t forget the NPN series base resistor, 1K should be fine.
Hope this helps.
Regards Ben Rowland - MatrixTSL
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel
Flowcode Product Page - Flowcode Help Wiki - Flowcode Examples - Flowcode Blog - Flowcode Course - My YouTube Channel