Spybots Smart Parts  
  The Unofficial Resource Centre for Lego Spybotic  
   
img  
   
   

TUTORIALS

TUTORIALS

BASIC

lighting up (PART 2)- mindscript

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.

  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