Tutorial Details:
Difficulty Level:
Basic
Topics Covered: Controlling
ARC lights using Mindscript.
Assumed Knowledge:
THe Basics, My
first program, Using Include,
Lighting Up (Part 1)
Written By: BILL LANE
Print Version
In Lighting Up (Part 1)
we looked at controlling the Spybot's lights using LED
[mode]. Which offered us a lot of control over the
various lights. There is another method of controlling the
ARC lights that offers a lot of flexibility in a single command.
That command is LED_Bead.
Like everything else in Mindscript if you want to use it you'll
need to declare it before the main command block. We can take
care of that by including spybot.h and globals.h (if you don't
know what I mean you'll need to go look at Using
Include ).
To work LED_Bead needs
4 pieces of information; they're commonly called parameters.
The full syntax including parameters looks like this: LED_Bead
(nLED, nBlink, nInterval, nTime). The first parameter
nLED is a number between
1 and 63 (it's actually up to 127 but the pattern just repeats
itself after 63) which represents an LED pattern. In other
words it tells the Spybot which lights to turn on. The second
parameter nBlink is exactly
the same except it tells the Spybot which LEDs to flash on
and off (set it to 0 if you don't want anything to flash).
The third parameter nInterval
tells it how long each blink should last for. The value is
in 100ths of a second. Therefore, using 20 will give you 5
flashes every second. The final parameter nTime tells it how
long to leave the lights on. It's also in 100ths of a second
so 100 leaves the light show on for 1 second. So let's see
the example:
program lightingUp
{
#include<spybot.h>
#include <globals.h>
main{
LED_Bead(21, 42, 20, 200)
}
}
In this example every second light (starting with the outside
Red) stays on while all the inbetween lights flash (5 times
per second). The whole thing lasts for 2 seconds then stops.
So how do we know what numbers turn on which lights? At the
bottom of this page you'll find a table that tells all. The
thing to note is that numbers run from the edge to the middle
of the Spybot. In other words 1R and 1G are both on the outside,
while 3R and 3G are both on the inside.
In Lighting Up (Part 3) we'll look at 8 preset ARC light
animations that we can easily access to add some sparkle to
our missions.
|