
[
click here for a printable version (PDF) of this page ]
PROP-1 101 :: Simple Light Flasher Using the RC-4
Welcome ladies and gentlemen, to the next installment of the Prop-1 101 Series at the GARAGE OF EVIL!!, in this suprisingly
morose yet uplifting tutorial, we'll show you how to hook up an RC-4, and flash a light a few times, using our Simple Push Button Trigger, that we
created in our last tutorial.
MATERIALS LIST
RELATED DOCUMENTATION (local)
WARNING: YOU ARE WORKING WITH ELECTRICITY HERE. YOU CAN SEVERELY HARM AND/OR KILL YOURSELF OR OTHERS. BE CAREFUL. WE ARE NOT RESPONSIBLE IF YOU DIE AND OR KILL OTHERS, OR EVEN BURN YOUR FINGER. BEFORE ATTEMPTING, PLEASE CLEAR YOUR BROWSER CACHE, YOU DO NOT WANT YOUR WIFE FINDING WHAT YOU'VE BEEN DOING ONLINE EVEN AFTER YOU ARE DEAD. DO NOT COME CRYING BACK TO US IF YOU BLOW A FINGER OFF. REMEMBER, SORRY DOESN'T GROW THUMBS BACK.
So, here you are now, with your prop-1 configured push button. Now what to do? Hey, let's make lights flash! (In a 'Randy from A Christmas Story' voice)
"A firetruck! Whoopieeee!".
Also, before we begin, so the code contained in this article works, make sure your trigger is on PIN0.
First thing you want to do, is if you look at the big EEPROM chip between the 3-PIN pin terminals row, and the green terminals on the Prop-1, if it says ULN2803 on it,
you will wnat to pick up a ULN2003A chip to replace it with. It is smaller, so
mount it into the same slot by making sure the end with the "divot" in it is down towards the PIN0 end of the pins, leaving the last pin PIN7 blank (see photo).

The reason we do this is because the ULN2803 chip has been known to cause issues with serial communications (connections to RC-4, FC-4, AP-8, etc.), so, by replacing it,
we will skip all of those woes, and get on to creating our little dream project of a flashing light. (In a 'Randy from A Christmas Story' voice)
"A firetruck! Whoopieeee!".
Now, we'll want to connect the 3 Pin connector cable from the Prop-1, to the RC-4 (see photo below).
Now, connect it so the WRB (White, Red, Black) is matched up to the board on the Prop-1 and the RC-4 (to serial pin - pick one, either will do just fine).
Not that it REALLY matters, but it needs to be a "straight-through" connection. White on one end should match White on the other, etc. If you reverse the other end, then
you're not going to be able to talk to it. Plus, you may just piss it off, and it kills you D-E-D dead. Hey, I warned you. Oh yeah, connect it to PIN6 on the Prop-1 (as shown above), so the code below works!

On to the RC-4. What we want to do next is attach one of the Crydom D2W203F Solid State Relays to
the first slot on the RC4 (closest to the dip switches, etc.), which is labelled K1. Once you've got that on there, for the purposes of this program,
we are going to set the serial address of the RC4 to %11. This is done setting the A1 and A0 pins so the connector is covering both pins.
Next, we need to hook up the light, and this is where you get to kill yourself! Woohoo! See the beautiful artwork rendered by our own Steve-O. Hack up
an extension cord (or use the cord already attached to your light), connect one end to your light, and the other end with the plug (LEAVE IT UNPLUGGED FOR NOW!)
can stay as-is. As you can see from the beautiful diagram below, you want to splice into one of the two wires going to the light. Once spliced, hook in the
two leads you have just created by splicing that wire, into the two ports on the K1 relay ports on the RC-4.
RC-4 Light Wiring Diagram

Wow. You're almost done. Upload this code into your prop-1, connect up everything, and run the code. It should quickly flash your light connected to the
RC-4 20 times each time you press your little trigger button. Now, go fourth, and conquer.
Click Here to Download the Code
' =========================================================================
'
' File...... GoE.Simple Light Flasher Using the RC-4.bs1
' Purpose... Simple Light Flasher Using the RC-4
' Author.... Geoff @ The GARAGE OF EVIL!!
' E-mail.... geoff@garageofevil.com
' Web....... http://www.garageofevil.com
'
' {$STAMP BS1}
' {$PBASIC 1.0}
'
' =========================================================================
' Input PINs
SYMBOL Trigger1 = PIN0 ' PIN 0 is our trigger
' Output PINs
SYMBOL RC4sio = 6 ' PIN 6 is our connection to the RC-4
' RC4 Settings
' set the baud rate at 2400 for the Prop-1 to RC-4 serial connection
SYMBOL RC4Baud = OT2400
' we're using address #11 (both A0 and A1 jumpers are on both pins)
SYMBOL RC4Addr = %11
' reserve a point in memory for our counter used in the Flash_Lights Subroutine
SYMBOL Counter = B1
Reset:
SEROUT RC4sio, OT2400, ("!RC4", RC4Addr, "X") ' reset all relays to OFF
Main:
' if the trigger was pressed, then run the Flash_Lights subroutine below
IF Trigger1 = 1 THEN Flash_Lights
GOTO Main
Flash_Lights:
' COUNT FROM 1 to 20, and run this code 20 times.
FOR Counter = 1 TO 20
' CLOSE THE RELAY CIRCUIT / TURN IT ON
SEROUT RC4sio, RC4Baud, ("!RC4", RC4Addr, "R", 1, 1)
' WAIT A SPLIT SECOND
PAUSE 25
' OPEN THE RELAY CIRCUIT / TURN IT OFF
SEROUT RC4sio, RC4Baud, ("!RC4", RC4Addr, "R", 1, 0)
' LOOP BACK UNTIL THE COUNTER REACHES 20
NEXT
GOTO Main
Click Here to Download the Code

This page was last modified on: November 21, 2007 01:42:05 pm