Tutorial Details:
Difficulty Level:
Basic
Topics Covered: Controlling
ARC lights using NQC.
Assumed Knowledge:
THe Basics, My
First Program, Using Include,
Lighting Up (Part 1)
Written By: BILL LANE
BACK
In Lighting Up (Part 1)
we looked at controlling the Spybot's lights using SetLED.
We sent it something like 0x01
to tell it which light to turn on. Using this we were able
to turn on one or all of the ARC lights. But it did become
rather cumbersome if we wanted to do anything fancy with the
lights. Well the good news is that there is another way.
Put simply all we need to do is send it a single number and
we can turn on whatever combination of ARC lights we can ever
need. In the following example we turn on all the red ARC
lights by sending it the number 7:
#include "spy.nqh"
task main()
{
SetLED(LED_MODE_ON, 7);
Wait (130);
}
How simple was that! This time we'll get all the red lights
to come on while all the green lights blink (we'll set the
blink rate in the first staement):
#include "spy.nqh"
task main()
{
SetLED(LED_MODE_DURATION,20);
SetLED(LED_MODE_ON, 7);
SetLED(LED_MODE_BLINK,56);
Wait (130);
}
The number 56 told the Spybot to flash all the green ARC
lights, just as the number 7 turned all the red ARC lights
on. So the real question is how do you know which number controls
which combination. Below is a table with the numbers for all
possible combinations. Some things to note: The number start
at the outside and work inwards. So 1R and 1G are the outside
red and green lights respectively (while 3R and 3G are the
middle lights). The documentation says that you can use number
between 1 and 127 and you can! But the sequence repeats itself
after 63. So that 64 is no lights, 65 is 1R etc, etc.
Which should be all you need to know to control your Spybot's
arc lights. There are some pre-defined animations that you'll
probably want to use. But I'll have to leave that for another
day. |