For this project a CGCOLORMAX was paired up with a relay shield. By using relays, you can control high voltages and currents. The four relays on this board are rated to handle up to 2 amps at up to 35 Volts DC.
A CGCOLORMAX1 board with a relay shield installed.
The newer revision (the CGCOLORMAX2) accepts shields in the same way.
You can turn on/off lights, motors, and even larger relays by using MMBasic to control the relays on a relay shield. Connections to COM and N.O. are like a switch that closes when the relay is energized.
Important parts of the relay shield annotated. Four sets of wires are connected to COM/N.O. and run off to the left to turn on some lights (not in picture).
The relay shield needs to be powered by an external DC supply of 7-12V DC through either the screw terminals or the 5.5/2.1 mm barrel jack. The external supply is regulated to 5V to power the relays.
The four relays are “Form C” which means that they each have a common connection that connects to the N.C. (normally closed) terminal when unpowered, and then to the N.O. (normally open) terminal when the relay is powered on.
The Direct I/O tab on MMIDE 3 can directly control the I/O of the shield connector. Here the appropriate lines are set to output.
Using MMIDE 3 it is pretty easy to set up the pins that are needed to operate the relays. D7 on the shield is relay #1. D6, D5, and D4 are relay #2, #3, and #4 respectively. These need to be set to output to control the relays.
MMIDE3 is again used for this relay control example. The on/off buttons associated with the lines that control the relay can be clicked to turn the relays on and off.
Relay #1 can be turned on/off in MMBasic by setting Pin 28 (same as D7 on the shield) to either 1 or 0.
' Set relay #1 line to output
SetPin 28, 8
' Turn relay #1 on
Pin(28) = 1
' Turn relay #1 off
Pin(28) = 0
' Set relay #2 line to output
SetPin 27, 8
' Turn relay #2 on
Pin(27) = 1
' Turn relay #2 off
Pin(27) = 0
If you happen to be powering the CGCOLORMAX with 8 to 12V DC, the same supply can also be wired to the relay shield to power it. Make sure that the power supply can provide the extra current needed to operate the relay shield.