
Using the CGMMSTICK or CGCOLORMAX might be very familiar or easy to understand for you, or you might be very new to all of this. Don’t worry about the first examples here if you are new to all of this. This document does assume that you have some hobbyist-level familiarity with electronics and also familiarity with the BASIC language.
Miscellaneous interfacing using the prototype for the CGMMSTICK. The CGMMSTICK development prototype pictured here was used for a lot of the initial CGMMSTICK testing.
Before getting into greater detail on the Maximite hardware, software, and the workings of the CGMMSTICK or CGCOLORMAX, I’d like to whet your appetite for the Maximite with a simple CGMMSTICK example.
It is easy to plug the CGMMSTICK into a white solderless breadboard and connect a USB cable to a PC to control the Maximite. This example demonstrates connecting an LED to one of the interface lines of the CGMMSTICK.
This introductory example uses a program that runs on PC/Linux/Mac as an aid to CGMMSTICK project development. The MMIDE program uses the serial port that is created when you connect the CGMMSTICK to your computer. The MMIDE program can be used as a terminal, as a way to transfer files, and to assist in hardware/software development.
CGMMSTICK1 mounted in positions 1-30 of the author’s solderless breadboard. The picture shows a solderless breadboard that is set up with the CGMMSTICK. The CGMMSTICK is plugged in to the solderless breadboard so that the numbered pins correspond to the numbers on the long connector. The 20 input/output lines of the CGMMSTICK are the connections on the right side. Ground, 3.3 volt, and 5 volt connections are some of the remaining pins on the right.
The electrical hardware used for this very simple example is a single LED and 330 ohm resistor. One CGMMSTICK output line is connected to the LED, and the resistor connects the other end of the LED to ground.
LED connected between I/O line #20 and a resistor (330 ohm) that goes to ground.
The picture shows the solderless breadboard with the LED example circuit. The I/O pin chosen was pin 20 (from software perspective which is pin 30 on the header), the connection farthest to the right on the CGMMSTICK. The breadboard is set up so that ground runs along the blue bus bar.
Pin 9 on JP1 (the CGMMSTICK header) is ground and attaches to the ground bus on the white solderless breadboard.
Select serial port and then click the Direct I/O page. Normally your developed BASIC code would be run to turn this LED on and off. But before doing that, the MMIDE development tool can be used to verify the LED circuit. Run MMIDE and select the appropriate serial port for the CGMMSTICK. Select the page tab to select the Direct I/O page.
Use the Blink LED Applet to test the LED that you have connected.
On the Direct I/O page you can see a little application called the “Blink LED Applet”. There are only two things to do to run this applet. First you select the I/O port connected to the LED. The little applet defaults to I/O pin #1, but can be changed to any of the 20 I/O pins.
In this example the I/O port used for the LED is port #20. Port #1 is the default when you first run the program, just select “20” from the drop-down menu.
After you have selected the port, press the “Blink” button. Your LED should start blinking. If it doesn’t, recheck your circuit. One common problem is a reversed LED – just flip it around.
If you press the “Blink” button a second time, the LED blinking will cease. MMIDE sends commands directly to the CGMMSTICK in order to make this little applet work. The applet sets the port line to be an output port, and then sends commands to turn that line on and off over and over. When done, make sure that you turn the blinking LED off.
I’ll mention again here that you might have wired up the LED circuit and could be clicking along with these instructions if you already have the CGMMSTICK and drivers installed, or you might just be reading along to learn what this version of a Maximite can do. The setup/installation process will be talked about in more detail later.
So you’ve just tethered the CGMMSTICK to your computer, added a simple LED circuit to it, and controlled that LED with MMIDE. But now what? Isn’t the little Maximite supposed to be the brains, not a big old computer running MMIDE? It is. To make it the brains, all you have to add is some BASIC code that you write and then run on the CGMMSTICK.
LED blinking BASIC program
If you return to the MMIDE page tab that says “MMBasic” you will be connected to the Maximite in a mode where you can type in your BASIC programs. This BASIC program in this example will do essentially the same thing as the MMIDE Applet did. Here is the program for you to enter:
1 2 3 4 5 6 |
10 SETPIN 20, 8 20 PIN(20) = 1 30 PAUSE 200 40 PIN(20) = 0 50 PAUSE 200 60 GOTO 20 |
This can also be done without line numbers in a text editor and downloaded to the CGMMSTICK. Here is what code without line numbers may look like:
1 2 3 4 5 6 7 8 9 10 11 12 |
' Set pin direction SETPIN 20, 8 ' Repeat forever DO ' Set pin high and pause PIN(20) = 1 PAUSE 200 ' Set pin low and pause PIN(20) = 0 PAUSE 200 LOOP |
You can run the program by entering the command “RUN” or you can click the green Run button. If you have entered the program correctly, the LED should be blinking while the program is running.
You can stop the blinking by typing Control-C or by clicking the red Stop button in MMIDE.
You can look up the commands in the program to see in detail what the program does at each step. In short, the program does about the same thing that the MMIDE “Blink LED Applet” does. The BASIC program sets the line (20) to be an output line, turns the line on, waits a little, turns the line off, waits a little, and then repeats.
This program can be saved to memory on the CGMMSTICK to be run again later. It can even be made to run automatically when the CGMMSTICK is powered up, so you would then have a fancy and overly sophisticated LED blinker. This fancy and overly sophisticated LED blinker has given you a good taste of what the CGMMSTICK Maximite can do.