SPLat Logo

My first flashing LED program

NOTICE: Our web site is being updated, but is currently experiencing extreme slowness due to host issues. Please contact us directly.
NOTICE: SPLat Controls has moved. We are now at 1/85 Brunel Rd, Seaford, 3198. map
SPLat will be shut down for the Christmas Holiday season from Friday 20 December 2024 through Tuesday 7 January 2025. We will check emails periodically and will continue to process orders but at a slower pace. Santa hat

This EasyStep will guide you through creating your first program for the EC1 EasyOne. It creates a flashing LED. This may not seem like much, but it will show you some essential principles of SPLat programming, including MultiTrack (32 processes for the price of one!).

It should take you between 1 and 2 hours to go through this.

Before starting on this, please be sure to have completed the EasyStep Getting started with SPLat/PC. Have your EC1 all hooked up via USB, and SPLat/PC running.

Now locate the Edit window of SPLat/PC. You are going to be typing your first program into that window, and then you are going to get the EC1 to run the program. Here's what the Edit window looks like, with the first line of the program typed in.

In brief, a program for an EC1 consists of a series of instructions that have been typed into the Edit window using the specific language of SPLat controllers. These instructions tell the board (in your case, the EC1) what steps to take to perform whatever function you want. The EC1 has a limited repertoire of instructions. You can only use those instructions it can understand, and you have to use them with exactly the correct spelling and in exactly the correct format.

Think of the EC1 as an incredibly dumb, unbelievably literal, but amazingly fast.

Here is the program. Before you type it in, move your mouse over each line in turn, starting from the top, and study the pop-up descriptions.

Loop   ON     0
       Pause  5
       OFF    0
       Pause  50
       GoTo   Loop	

Once you have read through the pop-up descriptions in the above program, you are ready to type it into the Edit window on SPLat/PC. Go ahead — type away! Your Edit window should end up looking like this:

Now would be a good time to save your program via the File menu. The file name will end in .spt

Before we go on, a little word of comfort: So long as you do not connect the wrong voltages to the EC1, or short circuit the wrong pins, you cannot damage the board or your computer. Programming the EC1 from your PC, powering it via the USB cable, can never do any harm. So even if any of the steps that follow don't give the expected result, you won't break anything.

Now you are going to transfer the program to your EC1 board and run it. At the moment, it exists only as a bunch of text in the SPLat/PC editor. In that form it's no use to the board — the program must be translated into the 1's and 0's that the board understands. You do this by invoking the Translate command under the File menu in SPLat/PC

You may wonder why it refers to "Module". That's what we called them back in the early days of SPLat. These days we prefer to use the term board, but we haven't changed the terminology in SPLat/PC.

Go ahead, do the translation. You should get a success message like this:

If you get an error message of some kind, double check all your typing. Does the "Loop" label start in column one? Are the key words spelled correctly?

Click the OK button

Now make sure your EC1 is plugged into the computer, and that it has connected to SPLat/PC. This was all done in the previous EasyStep. Your Module window should look substantially like this:

Now we are ready to transfer the translated program (all 15 bytes of it!) to the board. Use the menu selection shown:

You should be rewarded with the following message:

So, follow the suggestion in the window, and click the Run button in the Module window.

You should see a flashing green LED on the EC1 board

Click the Stop button on the Module window to stop the program and give control of the board back to SPLat/PC.

Congratulations, you have just achieved the following.

Of course, SPLat has a lot more than 14 instructions. We stopped counting at 450. But the nice thing is that you can get an observable result with just 4 instructions and 5 lines of code. As you have seen, you can get a result quickly, but the depth and scope of the SPLat instruction repertoire means you can grow into it gradually as you gain understanding, experience and ambition.

Next: Take a break. Stretch your legs. Have a cup of your favourite beverage — but keep a clear head, because you ain't seen nothing yet!

Come back in 10 minutes!


OK, back again?

Just for a little warmup, try the following exercises:

  1. Modify the program for different timings. Make the LED flash faster, or slower;
  2. Change to output 1 instead of 0. Make sure you change both relevant lines of code;
  3. Explore Menu   File > Translate and Go!. You should quickly discover that if the board is connected to SPLat/PC, Ctrl+F12 is the fastest way of getting an updated program running in the board;
  4. Modify the program to give 2 short flashes and one long flash. You will have to add a few lines of code;
  5. In 25 words or less, describe what is difficult about this. If you get more than one word, please write to us.

Now for our promise of 32 processes for the price of one...

What you are now going to do is make two copies of your LED flasher program, using different outputs (guess what, outputs 0 and 1), and with a different line label for the GoTo In fact, we will change the label name(s) to RedFlash and GreenFlash

Use the copy and paste edit commands (good old Ctrl+C—Ctrl+V) to make two copies of the program, and edit the output numbers, line labels and GoTo instructions so you wind up with something that looks like this: (No pop-ups on this one!)

RedFlash   On        1
           Pause     5
           Off       1
           Pause     25
           GoTo      RedFlash
		  
GreenFlash On        0
           Pause     5
           Off       0
           Pause     26
           GoTo      GreenFlash

If you try to run the above code, what will happen? Well, when it gets down to the line GoTo RedFlash it will jump back up to the line labelled RedFlash. The GreenFlash stuff won't get a look-in. Try it if you don't believe me!

But if I make one simple addition, I can make it do both flashing tasks at once. Run your mouse over the first 3 lines of this:

           LaunchTask    RedFlash
           LaunchTask    GreenFlash
           RunTasksForever
RedFlash   On        1
           Pause     5
           Off       1
           Pause     25
           GoTo      RedFlash
		  
GreenFlash On        0
           Pause     5
           Off       0
           Pause     26
           GoTo      GreenFlash

Can you see how adding just the two instructions LaunchTask and RunTasksForever to your repertoire allows you to make the EC1 do several things at once? In fact it can do 32 things at once — 32 processes for the price of one!

News flash: EC1 now supports 64 simultaneous tasks!

Translate the program and run it in your EC1. The two LEDs will flash, but at slightly different rates. The visual effect is that they slip in and out of synchronisation with each other.