| Armed with that information let's have
a look at another mode. If we want the lights to blink we
can use LED_MODE_BLINK.
For values we either tell it which lights to blink or send
it 0 to stop blinking. Before we look at the code let's look
at LED_MODE_DURATION.
We use this to tell the spybot how long the blink should last.
The value represents the duration in 100ths of a second. So
let's see an example:
SetLED(LED_MODE_DURATION,50);
SetLED(LED_MODE_BLINK, 0x01+0x20);
Wait (100);
N.B. The Spybot has a
default blink rate. But if you change the duration using this
mode it will retain that blink rate until you change it in
code or restart the Spybot.
In this example, the two outside lights will go on and off
twice before the program ends. With that knowledge under your
belt you might want to experiment with creating your own light
sequences before we move on.
The next series of modes we'll look at are those involving
the ALERT light. They are: LED_MODE_YELLOW,
LED_MODE_YELLOW_BLINK,
LED_MODE_YELLOW_DURATION
and they work in a very similar fashion the first three we
discussed. The biggest difference being that with only one
alert light we can turn it on using 1 and off using 0. The
following example turns tells the alert light to blink for
1 second:
SetLED(LED_MODE_YELLOW_DURATION
, 20);
SetLED(LED_MODE_YELLOW_BLINK
,1);
Wait(100);
Add the following code and it will stay on for another second
without blinking before turning off completely:
SetLED(LED_MODE_YELLOW_BLINK
, 0);
SetLED(LED_MODE_YELLOW,1);
Wait(100);
SetLED(10,0);
We can also use this command to control the VLL ( the laser
) light in a very similar way. The relevant modes are;
LED_MODE_VLL, LED_MODE_VLL_BLINK,
LED_MODE_VLL_DURATION.
There is one big difference here. If you don't expressly turn
off the VLL it will remain on after the program ends. The
other issue is that it's not enough just to tell it to stop
blinking. So if you start it blinking you need to stop the
blinking and then turn the light off. Here's the code:
SetLED(LED_MODE_VLL_DURATION,5);
SetLED(LED_MODE_VLL_BLINK,1);
Wait (100);
SetLED(LED_MODE_VLL_BLINK,0);
SetLED(LED_MODE_VLL,0);
So that's it you can now turn all the Spybot's lights on
and off as often as you like. There is a different way of
using SetLED that offers more control over which ARC lights
do what. But it's a bit much for this tutorial. If you're
ready for the next step take a look at Lighting
Up (Part 2). |