Spybots Smart Parts  
  The Unofficial Resource Centre for Lego Spybotic  
   
img  
   
   

TUTORIALS

TUTORIALS

BASIC

lighting up (part 2) - NQC

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.

  GREEN LIGHTS
  no G 1G 2G 1G/2G 3G 1G/3G 2G/3G all G
no Red 0 8 16 24 32 40 48 56
1R 1 9 17 25 33 41 49 57
2R 2 10 18 26 34 42 50 58
1R/2R 3 11 19 27 35 43 51 59
3R 4 12 20 28 36 44 52 60
1R/3R 5 13 21 29 37 45 53 61
2R/3R 6 14 22 30 38 46 54 62
all Red 7 15 23 31 39 47 55 63

 

This tutorial is protected by International Intellectual Property Rights laws and may not be reproduced or redistributed in full or part, without the prior written consent of the author. Unauthorized reproduction of this tutorial or its contents may result in prosecution.

 

 
 
DISCLAIMER: All content is provided as is, with no warranty stated or implied regarding the quality or accuracy of any content on or off this site. All trademarks, service marks, and copyrights are property of their respective owners. This site is not sponsored, authorized or sanctioned by the LEGO Group nor representative of their opinions in any way.PRIVACY POLICY