Custom functions
Info
At the moment available in Android only. For iOS use Override commands as alternative.
Normally the buttons inside Totem app are mapped to motor outputs directly. If we press a button - motor starts to spin, and stops on release. This is quite limited functionality. RoboBoard allows to have custom actions programmed and we will make an example of waving a servo motor arm. For full feature list read Totem App section.
Adding control button
Note: This is example from older app version and interface looks slightly different.
For more about buttons editing read Setting up Totem robot controls.
- Power on RoboBoard.
- Connect with Totem App.
- Create a new model.
- Add button.
- Go to button edit.
- Select RoboBoard and add
functionA
. - Click Next → Done → Save.
- Select Play mode.
Now, when we click this button, a value 100
will be sent to command functionA
. On release - -100
. These values can be changed by adjusting the slider. RoboBoard can intercept this command and read its value. By doing so, we can program a certain tasks to execute. There are 4 auxiliary commands in total: functionA
, functionB
, functionC
, functionD
and each one can be used.
Moving servo motor
We will write a code to wave servo arm. The motor itself is connected to servo channel A. Arm can move 180 degrees, and parameter values corresponds in range from -100
to 100
. Look at the image below to see how it's related:
So, we will try to move arm in this sequence: -45°, 0°, 45°, 0°. The code required to do so:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
|
Inside function loop()
we are calling moveServo()
to execute sequence and it is repeated every 2 seconds. The result should look like this:
Detecting App button press
Now let's move this servo arm only when in-App button is pressed. As bonus, we will indicate button press with on-board LED. To detect command events we need to add a little bit more code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
|
After uploading this code to RoboBoard - connect with Totem App and try pressing created button. Servo arm should move and LED light up.
For more information about Totem App events read TotemApp
section.