EasyManuals Logo
Home>LEGO>Toy>MINDSTORMS Robots

LEGO MINDSTORMS Robots User Manual

LEGO MINDSTORMS Robots
226 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #149 background imageLoading...
Page #149 background image
It's little cumbersome to always refer to the full name of the Spirit.ocx control. A simpler syntax, using With, looks like this:
Sub HelloSpiritII ()
With DummySpiritForm.Spirit1
.InitComm
.PlaySystemSound 0
.CloseComm
End With
End Sub
Page 163
Immediate and Delayed Gratification
The functions in Spirit.ocx can be immediate, delayed, or both. An immediate function executes as soon as you call it. Delayed functions can be placed inside a program and executed later. For
example, Onis both an immediate and delayed function. You can call it to turn on some outputs immediately, or you can call it to add it to a program that will be executed later.
The following subroutine plays a little song using the PlayTone function in its immediate mode:
Sub Charge()
With DummySpiritForm.Spirit1
.InitComm
.PlayTone 392, 10
.PlayTone 523, 10
.PlayTone 659, 10
.PlayTone 784, 20
.PlayTone 659, 10
.PlayTone 784, 20
.CloseComm
End With
End Sub
Instead of executing things on the RCX immediately, you can store them for later. The following subroutine redefines Program 5 on the RCX to play the same song:
Sub ChargeProgram()
With DummySpiritForm.Spirit1
.InitComm
.SelectPrgm 4
.BeginOfTask 0
.PlayTone 392, 10
.PlayTone 523, 10
.PlayTone 659, 10
.PlayTone 784, 20
.PlayTone 659, 10
.PlayTone 784, 20
.EndOfTask
Pause 1
.CloseComm
End With
End Sub
Sub Pause(ByVal duration As Integer)
Start = Timer
Do While Timer < Start + duration
Loop
End Sub

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the LEGO MINDSTORMS Robots and is the answer not in the manual?

LEGO MINDSTORMS Robots Specifications

General IconGeneral
BrandLEGO
ModelMINDSTORMS Robots
CategoryToy
LanguageEnglish

Related product manuals