To LUGNET HomepageTo LUGNET News HomepageTo LUGNET Guide Homepage
 Help on Searching
 
Post new message to lugnet.roboticsOpen lugnet.robotics in your NNTP NewsreaderTo LUGNET News Traffic PageSign In (Members)
 Robotics / 15487
15486  |  15488
Subject: 
Writing And Running A SoftBricks Program
Newsgroups: 
lugnet.robotics
Date: 
Thu, 24 May 2001 06:05:00 GMT
Viewed: 
812 times
  
This post is part of an ongoing series designed to introduce SoftBricks to
the MindStorms community. SoftBricks can be downloaded for free at
http://www.geocities.com/dave_leeper/Robots/SoftBricks.htm

This installment shows how to use SoftBricks from any application that
supports Visual Basic for Applications, such as Microsoft Excel. It assumes
that SoftBricks has already been installed on the computer.

Setting Up Visual Basic For Applications

Step 1
Open Microsoft Excel. Under the Tools menu, select the Macros submenu, and
then select Visual Basic Editor. If you don’t have Excel, you may use
Microsoft Word, Microsoft Visual Basic, or any program that can run Visual
Basic programs.

Step 2
Select the Insert menu and then select Module.

Step 3
Once in the Visual Basic IDE, select the Tools menu and then select
References.... Select SoftBricks and click OK. You are ready to begin
writing code using SoftBricks!

Running The Visual Basic Program

Step 1
Make sure the IR tower is plugged into your computer and the RCX is turned on.

Step 2
Select the Run menu and then select Run Sub/User Form. From the dialog box
that appears, select the subroutine you've written and click OK.

The program will download into your RCX.

Microsoft Excel Example
Here is a sample program you can write in Microsoft Excel using Visual Basic
for Applications to make the robot play a song.

Public Sub Main()
GetRCX.m_Downloader.BeginDownload GetRCX
        GetRCX.m_Sound.PlaySong Songs.SongCharge
GetRCX.m_Downloader.EndDownload
End Sub

This program causes the robot to play a short song. When you execute this
code, you’ll notice that it runs immediately. This is because the code was
not assigned to any RCX program. When the Downloader encounters this
situation it always executes the code immediately. This is called an
immediate mode program.

To run the same code but assigning the code to program 5, assign a program
object to the appropriate RCX program member and load the code into Task 1,
as shown in the following program.

Public Sub Main()
    Set GetRCX.m_Prog5 = New RCXProgram
    GetRCX.m_Downloader.BeginDownload GetRCX
        GetSpirit.BeginOfTask TaskNumbers.Task1
            GetRCX.m_Sound.PlaySong Songs.SongCharge
        GetSpirit.EndOfTask
    GetRCX.m_Downloader.EndDownload
End Sub

Now the program will only execute when you run RCX program 5.

Using Other Languages
SoftBricks is an ActiveX code component. This means you can use SoftBricks
with any language that supports ActiveX, such as Microsoft Visual C++,
Microsoft J++, Borland C++, or PowerSoft PowerBuilder, to name a few. Please
see the documentation that comes with your development environment to see if
it supports ActiveX and how to integrate ActiveX components into your programs



Message is in Reply To:
  SoftBricks Class And Object Model
 
SoftBricks is a collection of ActiveX objects designed to make programming the LegoMindstorms robots simply, powerful, fast, and fun. This post is part of an ongoing series designed to introduce SoftBricks to the MindStorms community. SoftBricks can (...) (24 years ago, 12-May-01, to lugnet.robotics)

2 Messages in This Thread:

Entire Thread on One Page:
Nested:  All | Brief | Compact | Dots
Linear:  All | Brief | Compact
    
Active threads in Robotics

 
Contact Recovery Nerd for Speedy USDT / BTC Recovery
23 hours ago
Custom Search

©2005 LUGNET. All rights reserved. - hosted by steinbruch.info GbR