Você está na página 1de 343

Zedomax DIY How-Tos by Max Lee from Zedomax.

com Table of Contents


Intro ................................................................................................................. 5 Zedomax DIY 100 Zedomax Alarm System How to Make an alarm system in 3 minutes! ......................................................................................................... 7 DIY100 - Parts List ........................................................................................... 7 Source Code .................................................................................................. 14 Zedomax DIY 101- How to Make a Touch screen Slotmachine & Blackjack in your car! 17 Parts List ....................................................................................................... 17 Source Code .................................................................................................. 23 Zedomax DIY 102 - Zedomax G-Meter - How to Make a G-Meter for your car in 1 minute!............................................................................................................ 28 Parts List ....................................................................................................... 28 Source Code .................................................................................................. 32 Taking it further... .......................................................................................... 33 Zedomax DIY103 - Zedomax Stopwatch - How to Make a stopwatch in 1 minute!....... 34 Parts List ....................................................................................................... 34 Source Code .................................................................................................. 36 Zedomax DIY104 - Zedomax Sprinkler System - How to Make a Touch-screen sprinkler system! ........................................................................................................... 38 Parts List ....................................................................................................... 40 Taking it Further............................................................................................. 44 Source Code .................................................................................................. 45 Zedomax DIY105 - Zedomax Party Light -How to Make a computer controlled Party Light in 90 seconds! .................................................................................................. 63 Parts List ....................................................................................................... 63

Connections ................................................................................................ 64 CODE Analysis... ............................................................................................ 65 Taking it Further............................................................................................. 65 Zedomax DIY106 - Zedomax Party Light II- How to Make a computer controlled Party Light Part II...................................................................................................... 66 Program Source... .......................................................................................... 69 Source Code .................................................................................................. 69 Taking it Further............................................................................................. 72 Zedomax DIY107 - Zedomax Wall Clock - How to Make a wall clock w/ temperature monitor from scratch! ........................................................................................ 73 Connections................................................................................................... 74 Program Source... .......................................................................................... 78 Taking it Further............................................................................................. 79 Zedomax DIY108 - Zedomax Alarm System II - How to Make an alarm system in 3 minutes! (Part II) - Add a motion sensor!........................................................... 80 Parts List ....................................................................................................... 80 Connections................................................................................................... 81 Program Source... .......................................................................................... 85 Taking it Further............................................................................................. 89 Zedomax DIY109 - Zedomax Digital Thermometer - How to Build a digital thermometer in 1 minute! ..................................................................................................... 90 Parts List ....................................................................................................... 90 Connections................................................................................................... 91 Taking it Further............................................................................................. 92 Program Source... .......................................................................................... 92 Zedomax DIY110 - Zedomax Digital Thermometer II - How to Make a Ethernet Temperature Monitor ......................................................................................... 94 Parts List ....................................................................................................... 95 Taking it Further............................................................................................101 Zedomax DIY111 - Zedomax User Interface Skeleton - How to Make a User Interface in 5 minutes! ......................................................................................................102 Parts List ......................................................................................................102 Taking it Further............................................................................................106 Zedomax DIY 112 - Zedomax Hovercraft Version 2 Asteroid How to Build a hovercraft! ......................................................................................................107 Parts List ......................................................................................................107 Taking it Further............................................................................................122 Zedomax DIY113 - Zedomax Hovercraft Version 3 - Asteroid II How to Build a bluetooth controlled Halloween Hovercraft party light! ..........................................123 Parts List ......................................................................................................124 HOWTO ........................................................................................................124 Taking it Further............................................................................................137 Zedomax DIY114 - Zedomax Halloween Picketfork LED How to Make a LED Trident! .....................................................................................................................141 Parts List ......................................................................................................141 HOWTO ........................................................................................................142 Taking it Further............................................................................................157 Zedomax DIY115 How to Establish serial connection with PC's bluetooth 2.0 with a ACODE-300! ....................................................................................................158

Parts List ......................................................................................................158 HOWTO ........................................................................................................159 Taking it Further............................................................................................166 Zedomax DIY116 How to Make make a Talking Halloween Basket! .......................167 Parts List ......................................................................................................168 HOWTO ........................................................................................................168 Taking it Further............................................................................................184 Zedomax DIY117 How to Make a Digital Drawing Board with an old joystick in 5 minutes! .........................................................................................................185 Parts List ......................................................................................................185 HOWTO ........................................................................................................185 Taking it Further............................................................................................194 Zedomax DIY118 How to Make a Golf Club POV training aid! - Golf Club POV - version Ben Hogan ......................................................................................................195 Parts List ......................................................................................................201 HOWTO ........................................................................................................201 Taking it Further...Applying to Swing Analysis....................................................222 Zedomax DIY119 - Make Christmas Light controller in 5 minutes! ...........................225 Parts List ......................................................................................................225 Source Code .................................................................................................230 Zedomax DIY120 How to Make Voice Activated Christmas Lights!.........................232 Circuit Explanation.........................................................................................233 Building the Controller....................................................................................233 Code Explanation...........................................................................................236 Zedomax DIY121 How to make your own PS3 SIXAXIS controller style BASICprogrammable USB device!................................................................................243 HID Portal ....................................................................................................243 Hardware Explanation ....................................................................................244 Building the HID Portal ...................................................................................245 Code Explanation...........................................................................................251 Zedomax DIY122 How to Make a LED Christmas Tree! ........................................254 Parts list.......................................................................................................257 Tub and shower piping ................................................................................257 PC Fan wrecking .........................................................................................259 Putting tub and shower piping and the FAN together...........................................260 Making the branches for the tree .....................................................................262 Start cutting the plastic branches you made! .....................................................264 Electronics....................................................................................................269 Put the LEDs on branches ...............................................................................269 Longer side branch wiring ...............................................................................270 Shorter side branch wiring ..............................................................................277 Put it together...............................................................................................280 Schematics ................................................................................................280 Source Code .................................................................................................282 Tips .............................................................................................................285 Taking it Further............................................................................................286 Zedomax DIY123 - HOW TO make a Christmas LED wreath!...................................287 Parts List ......................................................................................................287 HOWTO ........................................................................................................288

Zedomax DIY124 - HOW TO make a $50 golf training aid for 5 bucks! .....................291 Parts List ......................................................................................................292 HOWTO ........................................................................................................292 Swing Analysis ..............................................................................................294 Zedomax DIY125 How to Make a Music Syncing Light Orb Alarm Clock!.................296 Intro............................................................................................................296 Parts List ......................................................................................................297 Light Orb Schematics .....................................................................................298 Build the CB280 Mini Proto-Board ....................................................................299 Light Orb Mods..............................................................................................299 Alarm Clock Mods ..........................................................................................304 Finished Pictures ...........................................................................................314 Source Code .................................................................................................315 Zedomax DIY127 - How to Make an Ethernet Controlled Color Organ!......................329 Pics: ............................................................................................................334 Zedomax DIY128 - HOW TO Make a Glowing Heart LED Night Light!........................335 Parts List ......................................................................................................336 HOWTO ........................................................................................................336

Intro

Hello there, my name is Max from Zedomax.com. This e-book is a product of my past work with Comfile products (www.ComfileTech.com). Let me tell you just a little bit of how I started in the web blogging business. First, it was 2003 when I graduated from University of California, Davis and I was trying to become a golf pro. Of course, I broke one of my fingers and couldnt really play for a year. During that time, I got a job working for a company making beds. Well after just couple months, I quit that job except I couldnt find a job anywhere. To make the matters for the better, I applied for jobs oversea in South Korea, where I immigrated from originally and I could read and write Korean fluently. That job I got was from a company called Comfile Technology. (www.comfile.co.kr) They decided to open U.S. headquarters, so after a year working in Korea, I came back to America with a job. (Yes, I actually brought a job from overseas for myself and also hired 2 people in America.) As the USA Headquarters Director at Comfile Technology Inc, I did a lot of guerilla marketing for the company by creating these fast and quick DIY How-Tos on various basic circuits and microcomputer programming. Well, during the time I was trying to publish my DIYs online, I stumbled onto the world of blogs. Of course, being a hardware/software hacker I am, I started Zedomax.com and started posting all of my DIYs there while also posting others peoples DIYs to make it an informative website anyone could visit daily, not just for my DIYs. Pretty soon, I got a new job at Keetsa, an eco-friendly mattress company. During that time, I started the business and the Keetsa Eco-friendly and Green Blog. Of course, being the person I am, I quit that job after couple months as I lost interest in the mattress business. Well, to make the story short, I ended up back in my ocean-view apartment in San Francisco, $40,000 in debt, with no job and no savings. I started focusing more on making money with blogs and began making more money than I ever did with any jobs. (You can read about that on my other blog at Zedomax.Biz) Well, even though I am not working at Comfile Technology anymore, I look back and see that these DIYs and HOWTOs could be helpful for those of you studying automation, robots, and other basic circuits so I decided to make this e-book and make it easy so you can have the whole thing in your laptop, computer, or even print it out for reference instead of trying to browse through my blog. The most fun part was when many of these DIYs got popular on Web 2.0 social networking sites such as Digg and my website began to seize.

Of course, for every fabulous DIY you create, theres always naysayers and whatnot, but I only made them so others could make similar DIY gadgets referring to this E-book instead of starting from scratch. I hope these DIYs can be of help and if you do enjoy them, please also visit my DIY blog Zedomax.com, where I feature many other DIYs around the world. I try to think of my blog as an extension of my subconsciousness that you are free to check out. Without further delay, I present you the 29 Best/Worse DIYs I have ever made in my life. Although I stopped supporting any of these projects, I can guarantee you that they work perfectly if you make it right (as proven in the videos) and you can always e-mail support to my old co-worker Garrett who still works at Comfile Technology. (His e-mail is garrett [at] cubloc.com or garrett [at] zedomax.com) Note: DIY120 and DIY121 were actually made by Garrett so if you have any questions on the Voice-Activated Christmas Lights or the USB HID Portal, Garrett will help you greatly. Most other DIYs were collaboration between me, Garrett, and Jackie at Zedomax.com. Enjoy! P.S. I am not a professional publisher/editor, so please excuse my hack job on this E-book. Note: Any pictures/content in this E-book is free to distribute, please make to reference back to http://Zedomax.com, thats all I ask in return for free content.

Zedomax DIY 100 Zedomax Alarm System How to Make an alarm system in 3 minutes!
1

29

DIY100 - Parts List

1 Magnetic Contact Switch 1 12VDC Piezzo Buzzer 1 2N3904 Transistor


Available at RadioShack

1 1 1 1

CB280 Start Kit CLCD420-B 4x4 Keypad Keypad Controller

Available at Comfile

Click HERE for Video DEMO on YouTube

Okay, today I was thinking that I needed an alarm system for my dog, so I decided to make a doggy door alarm system. Since my dog sleeps w/ me, I needed to make an alarm system for the night, to protect my apartment from other intruding dogs... Anways, you might think I am crazy making an alarm system for furry people... Before I made the actual system, I decided to do it with a study board that has a little breadboard. You can get a 12VDC Piezzo Buzzer from your local Radio Shack for about 10 bucks and magnetic contact switches w/ screws for about 5 bucks. These magnetic contact switches are neat, they are the same ones used for a lot of residential and commercial door sensors.

They are simply magnetic switches. If door is closed, the contact is open and if door is open, the contact is closed. You can screw them into door and the wall using the holes on the switch ends. Yes, if you got that and some CUBLOC or any type of microcontroller w/ i/o ports, you should be ready to go. Here, we will use Comfile's CB280 embedded computer module and a 4x4 keypad and keypad controller, which will make things easier for us since we won't have to build from scratch.

(Close-up) You will need to solder on your Keypad to the Keypad Controller first. Then plug in black wire to GND, red wire to 5V, and rest of the pins to ports P0, P1, P2, and P3. (labeled 0, 1, 2, and 3 on the black IDC headers)

Once you are done connecting the Keypad Controller to your study board, connect the LCD to connector labeled, "CuNET".

Yes, now you have a keypad and an LCD. Now connect the black wire of the piezo to GND and red wire to the left side of the 3904 transistor. Connect 5V to the right side of the 3904 transistor. Connect the middle pin of the transistor to P5 of the CUBLOC Study Board (labeled "5").

Now why are we using a transistor? Because the piezo takes about 150mA and each I/O of CB280 CUBLOC module only can take so much (<50mA). So when the I/O port goes on, the transistor will simply connect power from 5V pin to the red wire of the piezo. Okay, now we have 1 more item, yes, that's right, we can put the magnetic contact switch. Connect one end of the Contact switch to 5V pin and the other end to port P20, labeled "20" on the study board.

Now connect a wire from P20 to an LED on the study board. This is to do a pull-down and we should be able to check the status of the contact switch using the LED. All right, now you are done, you should have something like this:

Now download this source file diy100.zip and uncompress it. You will find HomeAutomation001.cul and HomeAutomation001.cub. Open HomeAutomation001.cul file in your CublocStudio. Download the program to CB280 module. When you move the bottom part of the magnetic contact switch, you should see the LCD displaying "open" and "close" while the piezo beeps. Now enter "1234" as password on the keypad controller. If you mess up, you can press "CNCL" button, which will clear the password. You should see the Alarm Status on the LCD go ON. Now when the door is open, you will hear the alarm go off.

30

Source Code

Const Device = CB280 #define MyPass 1234 Set Pad 0,1,5 Const Byte KEY_TABLE=(0,0,14,16,0,15,0,0,0,0,13,9,8,7,0,0,0,0,12,6,5,4,0,0,0,0,11,3,2,1) 'Key table if Keypad inserted backwards to the Keypad Controller 'Const Byte KEY_TABLE=(0,0,1,4,7,10,0,0,0,0,2,5,8,11,0,0,0,0,3,6,9,12,0,0,0,0,13,14,15,16) Dim X As Byte 'Status of Alarm Dim AlarmON As Byte 'Status of Door Dim Door As Byte Dim Password As Long Door=0 Password=0 AlarmON=0 'Set port P5 to output Output 5 'Set Magnetic Switch to input Input 20 On INT0 Gosub GETINT Set int0 2 On Pad Gosub PAD_RTN Set Ladder Off Set Display 2,0,0,128 Cls Delay 100 Csroff Locate 0,0 Print "Zedomax Alarm System" Locate 0,2 Print "Door is: " If In(20)=1 Then Print "open" Else Print "closed" End If If AlarmON=1 Then Locate 0,3 Print "Alarm Status is ON" Else Locate 0,3 Print "Alarm Status is OFF"

End If Do If AlarmON=1 And Door=1 Then Alarm End If Loop GETINT: Door=In(20) Debug "Door: ",Dec Door,Cr Alarm If Door=0 Then Locate 9,2 Print "closed " Debug "door closed",Cr Else Locate 9,2 Print "open " Debug "door open",Cr End If Delay 500 Return

PAD_RTN: Peep X=Getpad(1) If X>29 Then Return X=KEY_TABLE(X) Debug "Key Pressed: ", Dec X,Cr If X < 10 Then Password=Password*10+X If Password > 9999 Then Password=X Debug "Password: ", Dec Password,Cr If Password = MyPass Then AlarmON=AlarmON Xor 1 If AlarmON=1 Then Locate 0,3 Print "Alarm Status is ON " Else Locate 0,3 Print "Alarm Status is OFF"

End If End If 'If ENTR pressed Elseif X=11 Then 'If CNCL pressed Elseif X=15 Then Password=0 End If Return End Sub Alarm() Out 5,1 Delay 100 Out 5,0 Delay 100 End Sub Sub Peep() Out 5,1 Delay 5 Out 5,0 Delay 5 End Sub

Taking it Further...
You can modify the source code to change the alarm times, scheduling, menus, etc...etc... The CB280 module supports up to 49 I/Os, so you can add up to 49 door sensors or you can add temperature chip to monitor temperature at the same time. The CB220 and CB220 Proto Board can be substituted for cheaper alternative. The CLCD420B can be substituted for smaller LCD such as the CLCD216G OR you can also add a graphic LCD, such as the GHLCD for expanding your alarm system... I will try to update w/ a touch screen alarm system for more high tech alarm system in the future w/ CuTOUCH.

Zedomax DIY 101- How to Make a Touch screen Slotmachine & Blackjack in your car!
2

Click HERE for Video Demo of Slotmachine on YouTube

Click HERE for Video Demo of BlackJack on YouTube

31

Parts List

1 12VDC Car Power Adaptor (Catalog #270-070) or any old car adaptors such as cell phone charger 1 DC Jack
Available at RadioShack

1 CuTOUCH CT1720
Available at cubloc.com

Okay today I was thinking and figured, why don't I just put a touch-screen slotmachine in my car? I am stuck in traffic 2 hours a day. So that's 2 x 5 days x 12 months = 120 hours a year. "I can gamble while I am waiting at the stop light," I figured. So you are thinking, "Doesn't this guy have something better to do?" Actually, this is the best thing I can think of right now of doing... The CuTOUCH runs on 9 to 24DC power so I figured I just needed to provide 12V from the cigarette lighter plug. Well since I just got a new LG cholcolate phone, I decided it was time to junk my Motorola V3 Car adaptor and put it to some good use.

(My Motorola V3 car phone adaptor)

(DC Jack) So once you have some type of car phone adaptor or a 12VDC Car Adaptor from RadioShack, you can make the following:

First and foremost, please disassemble your car phone adaptor like this:

(1: Just uncrew the head part and it should all disassemble)

(2: You will see some type of fuse at the head and some type of board connected to it.)

(3: Just Cut the board with your sissors, making sure you have enough wire to work with)

(4: Solder to the DC Jack, The one w/ the Fuse is the POSITIVE and the other one is GND. On the DC Jack side, you should see dotted line on the wire for the GND and the other one is POSITIVE!)

(5: Now screw back on your car adaptor and you have a Car-adaptor for your touch-screen computer)

Now once you've done that, simply plug the DC Jack into your CuTOUCH unit. Goto your car and plug in the new car adaptor you made into the cigarette lighter port like shown here:

Now place the touch screen unit on top of your dash-board until someone can think of a way of mounting it securely.

Now load the Slot machine program and play Slots w/ your touch screen computer!

32

Source Code

Slot machine program download here

Or you can download the BlackJack program and play. BlackJack program download here

(main screen)

(Playing Game)

(Dealer BUST!)

(BlackJack ready for traffic)

Next time, let's see if we can get deeper into other apps...

Zedomax DIY 102 - Zedomax G-Meter How to Make a G-Meter for your car in 1 minute!

Click HERE to see Assembly of G-Meter in 1 Minute on YouTube Click HERE to see G-Meter in action on YouTube

33

Parts List

1 Buffered 3D Accelerometer $35


Available at DimensionEngineering

1 CB220 Start Kit $99 1 CVFD-216 $54

Available at Comfile Technology

Today I received my accelerometer from Dimension Engineering, I was so excited and couldnt wait to start making something w/ it. So I figured I could follow the app note on their web site for making a G-meter. I figured that I could just do it with the CB220 module and a Plug-N-Play LCD from Comfile in matter of minutes.

The following is the accelerometers pin outs from the product data sheet:

The accelerometer has a 3.3V regulator so we can use the 333mV/g as sensitity for our G-meter.

Since the CUBLOC CB220 module has analog inputs, we can simply connect X, Y, Z analog outputs of the accelerometer to the AD pins on the CB220.

Make connections like shown below:

(Close-up of connections on the study board) Then, you can connect the LCD using the connectors.

When done, you should have something like above. Simply download the Accelerometer.zip and download to your CB220 module using CublocStudio. Now you should be able to get 1G on your LCD readings when you move your study board vertically and horizontally.

Now go to your car and strap the study board on to your center console like this:

(Study Board Strapped to center Console of my car) And then place the LCD on your dashboard.

(LCD on the dashboard) When you accelerate, you should see Y increasing and when you decelerate, you should see Y decreasing. When you turn left or right, you will see X changing.

Next time, I will have to try this on my motorcycle. It seems like my car can handle up to about 0.4Gs at the most. You can see in the video when the vehicle is decelerating, the Gs are negative. You can modify the code to have a calibration of your G-Meter by noting the voltage output when the G-Meter is at a complete stop. Oh yeah, here a link to how to make the stopwatch used in the video: Link

34

Source Code

[Accelerometer001.cul] Const Device = CB220 #define CALIBRATE 1.674805 Dim X As Integer Dim Y As Integer Dim Z As Integer Dim sX As Single Dim sY As Single Dim sZ As Single Dim gX As Single Dim gY As Single Dim gZ As Single Dim strX As String Dim strY As String Dim strZ As String 'Set P0, P1, and P2 to input Input 0 Input 1 Input 2 Set Display 2,0,0,128 X=1 Cls

Delay 100 Csroff Do X=Tadin(0) Y=Tadin(1) ' Z=Tadin(2) sX=(X*5.0)/1024.0 sY=(Y*5.0)/1024.0 ' sZ=(Z*5.0)/1024.0 gY=(sY-CALIBRATE)/0.333 gX=(sX - CALIBRATE)/0.333 ' gZ=(sZ - CALIBRATE)/0.333 Debug Goxy,0,0,"X axis: ",Dec X,Cr Debug "X voltage: ",Float sX,Cr Debug "X G: ",Float gX,Cr strX=Float gX strX=Left(strX,5) 'Print to LCD Locate 0,0 Print "X: ",strX Debug Goxy,0,4 Debug "Y axis: ",Dec Y,Cr Debug "Y voltage: ",Float sY,Cr Debug "Y G: ",Float gY,Cr strY=Float gY strY=Left(strY,5) 'Print to LCD Locate 0,1 Print "Y: ",strY ' ' ' ' Display 0,Float gY Debug "Z axis: ",Dec Z,Cr Debug "Z voltage: ",Float sZ,Cr Debug "Z G: ",Float gZ,Cr Delay 300 Loop End

35

Taking it further...

You can probably do some acceleration calculations to get your mph, keep track of 1/4 mile times, etc...etc...

Zedomax DIY103 - Zedomax Stopwatch - How to Make a stopwatch in 1 minute!


4

Today I was trying to make the G-meter and was thinking that I needed a stopwatch. Well since I don't carry watches and I didn't want to buy a stopwatch, I figured I could just make one with some of the extra study board and seven segment displays I have laying around.

Click HERE to see Video DEMO on YouTube

36

Parts List
$119 $54

1 CB280 Start Kit 1 CSG-4M

Available at Comfile Technology

Make connections like shown below:

Simply download StopWatch.zip and use CublocStudio to download the program. The first pushbutton is connected to P0 of the CB280 and second pushbutton is connected to P1 of the CB290. Simple, the first pushbutton is used for starting and stopping the stopwatch. The second pushbutton is used for resetting it to zero. Now I am glad I have a stopwatch so I can have it around for future projects...

37

Source Code

[stopwatch001.cul] 'Simple StopWatch Const Device = CB280 Dim Duration As Long Dim Power As Byte Power=0 Duration=0 'Start & Stop button Input 0 'Reset Button Input 1 Set I2c 9,8 Display 0,Dp(Duration,4,1) On timer(10) Gosub timer_rtn

Do Loop timer_rtn: If Power=1 Then Incr Duration Display 0, Dp(Duration,4,1) End If If In(0)=1 Then Power=Power Xor 1 Elseif In(1)=1 Then Duration=0 display 0,Dp(Duration,4,1)

End If Return End Sub Display(dID As Byte, DStr As String) Dim ct2 As Byte,ct As Byte Debug "D: ",Dstr,Cr ct2=0 For ct=0 To 3 If ct=2 Then Csgnput dID,ct, DStr_a(ct) Or 0x80 Else Csgnput dID,ct, DStr_a(ct) 'And 0x80 End If Next End Sub

Zedomax DIY104 - Zedomax Sprinkler System - How to Make a Touch-screen sprinkler system!
5

Couple months ago, my friend's sprinkler contol system broke, so I decided to build him one using a touch screen controller. The other day, I went to Home Depot and I've noticed there was no touch screen sprinkler system on the market yet, or at least not at Home Depot. Anyways, today I will show you how to make one and let you have access to my sprinkler program source code too. Since I don't own a house like my friend and live out of a garage, I will have to simulate the water pressure using a water pump.

See video of Zedomax Sprinkler System in Action on YouTube

(yes, I went here)

(No touch-screen sprinkler systems here)

38

Parts List
$59 $12 $12 $20

1 Utility Pump 1 Sprinkler Valve 1 Sprinkler Various pipe fittings


Available at Home Depot

1 CT1721 Kit 1 Relay8 Board

Available at Comfile Technology

$399 $29

Estimated Time to Buy Parts: 30min Estimated Time to Assemble: 20min

If you goto Home Depot, you will find lots of sprinkler valves, just pick one they are all the same I think...

Get a sprinkler or get whole bunch of them... Connections

Connect the Relay8 Board to like shown below:

Then connect the sprinkler valve(solenoid) to the Relay8 board.

(yes, there's only 2 wires on the valve) The valve is powered by the on-board 24V DC power of CT1721, but you will have to use 24VAC for the real thing. The Relay8 board supports both AC and DC, so you should be okay.

Then connect hoses, one to the water pump, the other going out to your sprinkler(s). One valve can support more than 1 sprinkler, please refer to the following howto links on calculating exactly how many sprinklers you can activate at one time: via [Lowes] via [zedomax]

(My sprinkler wedged on the door)

(My water pump to simulate water pressure)

(Experimental setup) Simply download sprinkler6.zip and use CublocStudio to download the program which are Program006.cul(LADDER CODE) and Program006.cub(BASIC CODE). I've used a combination of BASIC and Ladder in this program to make one helluva sprinkler program...I think...

39

Taking it Further...

The current program is pretty stable I think, but hopefully, I can add a temperature sensor to stop the sprinkler on hot days and add a humidity sensor for rainy days. It must be working well since my friend is not complaining about it. You can add up to 32 sprinkler valves, well the program is for 12 right now, you will have to modify it to fit 32... That means at 5 sprinklers per sprinkler valves, you could possibly hook up 160 sprinklers and control them. Well to take it even further, you can use modbus to connect 127 touch screen controllers and control 127 * 160 = 20,320 sprinklers! Well, that might not be case unless you own a golf course...

40

Source Code

[sprinkler006.cul]
Const Device = CT1720 #define PZ Pulsout 18,50 #define Bdelay 200 Usepin 32, Out, relay1 Usepin 33, Out, relay2 Usepin 34, Out, relay3 Usepin 35, Out, relay4 Usepin 36, Out, relay5 Usepin 37, Out, relay6 Usepin 38, Out, relay7 Usepin 39, Out, relay8 Usepin 40, Out, relay9 Usepin 41, Out, relay10 Usepin 42, Out, relay11 Usepin 43, Out, relay12 Set Ladder On Dim TX1 As Integer, TY1 As Integer Dim Contrast_Setting As Integer Dim mode As Byte Dim sec As Byte, min As Byte, hr As Byte, date As Byte, day As Byte, month As Byte, year As Integer Dim sec2 As Byte, min2 As Byte, hr2 As Byte, date2 As Byte, day2 As Byte, month2 As Byte, year2 As Integer Dim programtype As Byte Dim prog(4) As Byte Dim relay(4) As Integer '2 bytes or 16 bits Dim relaynumber As Byte Dim AUTO As Byte Dim relaytimes(13) As Integer Dim ProgramHour(4) As Byte Dim ProgramMin(4) As Byte Dim mm(12) As Byte Dim disa(13,4) As Integer Dim qqq As Byte Dim mmode As Byte Dim onebyte As Integer Dim relaysON As Byte relaysON=0 ' ManualON=0 mmode=0 For qqq=0 To 11 relaytimes(qqq)=Eeread(2+(qqq*2),2) If relaytimes(qqq)=65535 Then relaytimes(qqq)=1 _D(qqq)=relaytimes(qqq) _M(qqq)=0 Next ' Timeset 0, 0x55 ' Timeset 1, 0x59'Bin2bcd(6) ' Timeset 2, 0x02'Bin2bcd(6)

' _M(0)=1 'Delay 10 _M(0)=0 ' Do ' Loop ' If AUTO>1 Then AUTO=0

relaynumber=0 mode=0 Cls Contrast_Setting=Eeread(0,2) If Contrast_Setting>1000 Then Contrast_Setting=580 Contrast Contrast_Setting ' Initialize all variables to 0, 0 is OFF 1 is ON Delay 500 gPrint "v.0.0.6" Delay 500 gPrint "v.0.0.6" Delay 500 gPrint "v.0.0.6" Delay 500 Cls Set Pad 0,4,5 ' When input received, jump to welovemax! On Pad Gosub welovemax On timer(35) Gosub Display mainmenu If AUTO.bit0=1 Then Menureverse 4 If AUTO.bit1=1 Then Menureverse 5 If AUTO.bit2=1 Then Menureverse 6 If AUTO.bit3=1 Then Menureverse 7 CurrentTime 1 Do Loop Display: CurrentTime 0 If mode=5 Then DisplayMTimes End If Return welovemax: '------Receive x, y values from TouchPAD!----------------------------------------------TX1 = Getpad(2) TY1 = Getpad(2) If mode=0 Then If Menucheck(0,TX1,TY1) = 1 Then PZ Menureverse 0 mode=1 Delay 250 Cls CurrentTime 1 setuptime Elseif Menucheck(1,TX1,TY1)=1 Then PZ Menureverse 1 mode=2 Delay 250 Cls CurrentTime 1 schedulemenu Elseif Menucheck(2,TX1,TY1)=1 Then PZ Contrast_Setting=Contrast_Setting+4 Debug Dec contrast_setting Contrast Contrast_Setting Eewrite 0,Contrast_Setting,2 Menureverse 2 Delay BDelay Menureverse 2 Elseif Menucheck(3,TX1,TY1)=1 Then PZ Contrast_Setting=Contrast_Setting-4 Debug Dec contrast_setting 'Schedule Menu ' Infinite Loop

'

'

Contrast Contrast_Setting Eewrite 0,Contrast_Setting,2 Menureverse 3 Delay BDelay Menureverse 3 Elseif Menucheck(4,TX1,TY1)=1 Then PZ Menureverse 4 Delay BDelay AUTO.bit0=AUTO.bit0 Xor 1 Elseif Menucheck(5,TX1,TY1)=1 Then PZ Menureverse 5 Delay BDelay AUTO.bit1=AUTO.bit1 Xor 1 Elseif Menucheck(6,TX1,TY1)=1 Then PZ Menureverse 6 Delay BDelay AUTO.bit2=AUTO.bit2 Xor 1 Elseif Menucheck(7,TX1,TY1)=1 Then PZ Menureverse 7 Delay BDelay AUTO.bit3=AUTO.bit3 Xor 1 Elseif Menucheck(8,TX1,TY1)=1 Then PZ Menureverse 8 Delay 250 mode=5 Cls CurrentTime 1 mmode=0 StatusMenu TurnOFF Elseif Menucheck(9,TX1,TY1)=1 Then PZ turnoff Menureverse 9 Delay 250 End If Elseif mode=1 Then If Menucheck(0,TX1,TY1) = 1 Then PZ If hr<23 Then hr=hr+1 Timeset 2, Bin2bcd(hr) End If Menureverse 0 Delay BDelay Menureverse 0 Elseif Menucheck(1,TX1,TY1)=1 Then PZ If hr>0 Then hr=hr-1 Timeset 2, Bin2bcd(hr) End If Menureverse 1 Delay BDelay Menureverse 1 Elseif Menucheck(2,TX1,TY1)=1 Then PZ If min<60 Then min=min+1 Timeset 1, Bin2bcd(min) End If Menureverse 2 Delay BDelay Menureverse 2 Elseif Menucheck(3,TX1,TY1)=1 Then PZ If min>0 Then min=min-1 Timeset 1, Bin2bcd(min) End If Menureverse 3 Delay BDelay Menureverse 3

Elseif Menucheck(4,TX1,TY1)=1 Then PZ If month<12 Then month=month+1 Timeset 5, Bin2bcd(month) End If Menureverse 4 Delay BDelay Menureverse 4 Elseif Menucheck(5,TX1,TY1)=1 Then PZ If month > 1 Then month=month-1 Timeset 5, Bin2bcd(month) End If Menureverse 5 Delay BDelay Menureverse 5 Elseif Menucheck(6,TX1,TY1)=1 Then PZ If date<32 Then date=date+1 Timeset 3, Bin2bcd(date) End If Menureverse 6 Delay BDelay Menureverse 6 Elseif Menucheck(7,TX1,TY1)=1 Then PZ If date > 1 Then date=date-1 Timeset 3, Bin2bcd(date) End If Menureverse 7 Delay BDelay Menureverse 7 Elseif Menucheck(8,TX1,TY1)=1 Then PZ Menureverse 8 Delay BDelay mode=0 Cls mainmenu If AUTO.bit0=1 Then Menureverse 4 If AUTO.bit1=1 Then Menureverse 5 If AUTO.bit2=1 Then Menureverse 6 If AUTO.bit3=1 Then Menureverse 7 currenttime 1 End If Elseif mode=2 Then If Menucheck(0,TX1,TY1) = 1 Then PZ Menureverse 0 Delay BDelay Menureverse 0 mode=3 Cls currenttime 1 programtype=0 programmenu showbuttons ProgramTime Glocate 10,200 Dprint "Program ",Dec programtype+1 Elseif Menucheck(1,TX1,TY1)=1 Then PZ Menureverse 1 Delay BDelay Menureverse 1 mode=3 Cls currenttime 1 programtype=1 programmenu showbuttons

ProgramTime Glocate 10,200 Dprint "Program ",Dec programtype +1 Elseif Menucheck(2,TX1,TY1)=1 Then PZ Menureverse 2 Delay BDelay Menureverse 2 mode=3 Cls currenttime 1 programtype=2 programmenu showbuttons ProgramTime Glocate 10,200 Dprint "Program ",Dec programtype+1

Elseif Menucheck(3,TX1,TY1)=1 Then PZ Menureverse 3 Delay BDelay mode=3 Cls currenttime 1 programtype=3 programmenu showbuttons ProgramTime Glocate 10,200 Dprint "Program ",Dec programtype+1

Elseif Menucheck(4,TX1,TY1)=1 Then PZ Menureverse 4 Delay BDelay mode=0 Cls currenttime 1 mainmenu If AUTO.bit0=1 Then Menureverse 4 If AUTO.bit1=1 Then Menureverse 5 If AUTO.bit2=1 Then Menureverse 6 If AUTO.bit3=1 Then Menureverse 7 Elseif Menucheck(5,TX1,TY1)=1 Then PZ Menureverse 5 Delay BDelay mode=4 Cls currenttime 1 relaymenu showrelaytimes relaynumber End If Elseif mode=3 Then If Menucheck(0,TX1,TY1) = 1 Then PZ prog(programtype).bit0=1 Xor prog(programtype).bit0 Menureverse 0 Elseif Menucheck(1,TX1,TY1) = 1 Then PZ prog(programtype).bit1=1 Xor prog(programtype).bit1 Menureverse 1 Elseif Menucheck(2,TX1,TY1) = 1 Then PZ prog(programtype).bit2=1 Xor prog(programtype).bit2 Menureverse 2 Elseif Menucheck(3,TX1,TY1) = 1 Then PZ prog(programtype).bit3=1 Xor prog(programtype).bit3 Menureverse 3 'goto relay time setting

Elseif Menucheck(4,TX1,TY1) = 1 Then PZ prog(programtype).bit4=1 Xor prog(programtype).bit4 Menureverse 4 Elseif Menucheck(5,TX1,TY1) = 1 Then PZ prog(programtype).bit5=1 Xor prog(programtype).bit5 Menureverse 5 Elseif Menucheck(6,TX1,TY1) = 1 Then PZ prog(programtype).bit6=1 Xor prog(programtype).bit6 Menureverse 6 'relay ON/OFF Elseif Menucheck(7,TX1,TY1) = 1 Then PZ relay(programtype).bit0=1 Xor relay(programtype).bit0 Menureverse 7 Elseif Menucheck(8,TX1,TY1) = 1 Then PZ relay(programtype).bit1=1 Xor relay(programtype).bit1 Menureverse 8 Elseif Menucheck(9,TX1,TY1) = 1 Then PZ relay(programtype).bit2=1 Xor relay(programtype).bit2 Menureverse 9 Elseif Menucheck(10,TX1,TY1) = 1 Then PZ relay(programtype).bit3=1 Xor relay(programtype).bit3 Menureverse 10 Elseif Menucheck(11,TX1,TY1) = 1 Then PZ relay(programtype).bit4=1 Xor relay(programtype).bit4 Menureverse 11 Elseif Menucheck(12,TX1,TY1) = 1 Then PZ relay(programtype).bit5=1 Xor relay(programtype).bit5 Menureverse 12 Elseif Menucheck(13,TX1,TY1) = 1 Then PZ relay(programtype).bit6=1 Xor relay(programtype).bit6 Menureverse 13 Elseif Menucheck(14,TX1,TY1) = 1 Then PZ relay(programtype).bit7=1 Xor relay(programtype).bit7 Menureverse 14 Elseif Menucheck(15,TX1,TY1) = 1 Then PZ relay(programtype).bit8=1 Xor relay(programtype).bit8 Menureverse 15 Elseif Menucheck(16,TX1,TY1) = 1 Then PZ relay(programtype).bit9=1 Xor relay(programtype).bit9 Menureverse 16 Elseif Menucheck(17,TX1,TY1) = 1 Then PZ relay(programtype).bit10=1 Xor relay(programtype).bit10 Menureverse 17 Elseif Menucheck(18,TX1,TY1) = 1 Then PZ relay(programtype).bit11=1 Xor relay(programtype).bit11 Menureverse 18 Elseif Menucheck(19,TX1,TY1) = 1 Then PZ Delay BDelay mode=0 Cls CurrentTime 1 mainmenu If AUTO.bit0=1 Then Menureverse 4 If AUTO.bit1=1 Then Menureverse 5 If AUTO.bit2=1 Then Menureverse 6 If AUTO.bit3=1 Then Menureverse 7 Elseif Menucheck(20,TX1,TY1) = 1 Then PZ Delay BDelay mode=2 Cls CurrentTime 1 schedulemenu Elseif Menucheck(21,TX1,TY1) = 1 Then PZ If ProgramHour(programtype)<23 Then ProgramHour(programtype)=ProgramHour(programtype)+1

ProgramTime Menureverse 21 Delay BDelay Menureverse 21 Elseif Menucheck(22,TX1,TY1) = 1 Then PZ If ProgramHour(programtype)>0 Then ProgramHour(programtype)=ProgramHour(programtype)-1 ProgramTime Menureverse 22 Delay BDelay Menureverse 22 Elseif Menucheck(23,TX1,TY1) = 1 Then PZ If ProgramMin(programtype)<59 Then ProgramMin(programtype)=ProgramMin(programtype)+1 ProgramTime Menureverse 23 Delay BDelay Menureverse 23 Elseif Menucheck(24,TX1,TY1) = 1 Then PZ If ProgramMin(programtype)>0 Then ProgramMin(programtype)=ProgramMin(programtype)-1 ProgramTime Menureverse 24 Delay BDelay Menureverse 24 End If Elseif mode=4 Then 'if relay menu then If Menucheck(0,TX1,TY1) = 1 Then PZ If relaytimes(relaynumber)<60 Then relaytimes(relaynumber)=relaytimes(relaynumber)+1 Eewrite 2+(relaynumber*2),relaytimes(relaynumber),2 End If showrelaytimes relaynumber Menureverse 0 Delay BDelay Menureverse 0 Elseif Menucheck(1,TX1,TY1) = 1 Then If relaytimes(relaynumber) > 0 Then relaytimes(relaynumber)=relaytimes(relaynumber)-1 Eewrite 2+(relaynumber*2),relaytimes(relaynumber),2 End If showrelaytimes relaynumber PZ Menureverse 1 Delay BDelay Menureverse 1 Elseif Menucheck(2,TX1,TY1) = 1 Then PZ Menureverse 2 Delay BDelay Cls mode=0 mainmenu If AUTO.bit0=1 Then Menureverse 4 If AUTO.bit1=1 Then Menureverse 5 If AUTO.bit2=1 Then Menureverse 6 If AUTO.bit3=1 Then Menureverse 7 CurrentTime 1 ' Elseif Menucheck(3,TX1,TY1) = 1 Then PZ Menureverse 3 Delay BDelay Cls mode=2 CurrentTime 1 schedulemenu Elseif Menucheck(4,TX1,TY1) = 1 Then PZ

If relaynumber<11 Then relaynumber=relaynumber+1 showrelaytimes relaynumber Menureverse 4 Delay BDelay Menureverse 4 Elseif Menucheck(5,TX1,TY1) = 1 Then PZ If relaynumber>0 Then relaynumber=relaynumber-1 showrelaytimes relaynumber Menureverse 5 Delay BDelay Menureverse 5 Elseif Menucheck(6,TX1,TY1) = 1 Then PZ relaytimes(relaynumber)=0 showrelaytimes relaynumber Menureverse 5 Delay BDelay Menureverse 5 End If Elseif mode=5 Then

If Menucheck(0,TX1,TY1) = 1 Then ' PZ ' ManualON 0 ' Menureverse 0 ' Delay BDelay Elseif Menucheck(1,TX1,TY1) = 1 Then ' PZ ' ManualON 1 ' Menureverse 1 ' Delay BDelay Elseif Menucheck(2,TX1,TY1) = 1 Then ' PZ ' ManualON 2 ' Menureverse 2 ' Delay BDelay Elseif Menucheck(3,TX1,TY1) = 1 Then ' PZ ' ManualON 3 ' Menureverse 3 ' Delay BDelay Elseif Menucheck(4,TX1,TY1) = 1 Then ' PZ ' ManualON 4 ' Menureverse 4 ' Delay BDelay Elseif Menucheck(5,TX1,TY1) = 1 Then ' PZ ' ManualON 5 ' Menureverse 5 ' Delay BDelay Elseif Menucheck(6,TX1,TY1) = 1 Then ' PZ ' ManualON 6 ' Menureverse 6 ' Delay BDelay Elseif Menucheck(7,TX1,TY1) = 1 Then ' PZ ' ManualON 7 ' Menureverse 7 ' Delay BDelay Elseif Menucheck(8,TX1,TY1) = 1 Then ' PZ ' ManualON 8 ' Menureverse 8 ' Delay BDelay Elseif Menucheck(9,TX1,TY1) = 1 Then ' PZ ' ManualON 9 ' Menureverse 9 ' Delay BDelay Elseif Menucheck(10,TX1,TY1) = 1 Then ' PZ ' ManualON 10 ' Menureverse 10 ' Delay BDelay Elseif Menucheck(11,TX1,TY1) = 1 Then ' PZ

' ManualON 11 ' Menureverse 11 ' Delay BDelay Elseif Menucheck(12,TX1,TY1) = 1 Then PZ Menureverse 12 Delay BDelay mode=0 Cls currenttime 1 mainmenu If AUTO.bit0=1 Then Menureverse 4 If AUTO.bit1=1 Then Menureverse 5 If AUTO.bit2=1 Then Menureverse 6 If AUTO.bit3=1 Then Menureverse 7 Elseif Menucheck(13,TX1,TY1) = 1 Then PZ ' ' onebyte=(relay(uu)>>qqq) And 0x01 _D(qqq)=relaytimes(qqq)*600*onebyte For qqq=0 To 11 onebyte=(relay(0)>>qqq) And 0x01 _D(qqq)=relaytimes(qqq)*600*onebyte Next If mmode=0 Then mmode=1 Elseif mmode=1 Then mmode=0 Elseif mmode=2 Then mmode=1 Menureverse 14 Elseif mmode=3 Then mmode=1 Menureverse 15 Elseif mmode=4 Then mmode=1 Menureverse 16 End If Menureverse 13 Delay BDelay Elseif Menucheck(14,TX1,TY1) = 1 Then PZ For qqq=0 To 11 onebyte=(relay(1)>>qqq) And 0x01 _D(qqq)=relaytimes(qqq)*600*onebyte Next If mmode=0 Then mmode=2 Elseif mmode=1 Then mmode=2 Menureverse 13 Elseif mmode=2 Then mmode=0 Elseif mmode=3 Then mmode=2 Menureverse 15 Elseif mmode=4 Then mmode=2 Menureverse 16 End If Menureverse 14 Delay BDelay Elseif Menucheck(15,TX1,TY1) = 1 Then PZ For qqq=0 To 11 onebyte=(relay(2)>>qqq) And 0x01 _D(qqq)=relaytimes(qqq)*600*onebyte Next If mmode=0 Then mmode=3 Elseif mmode=1 Then mmode=3 Menureverse 13 Elseif mmode=2 Then

mmode=3 Menureverse 14 Elseif mmode=3 Then mmode=0 Elseif mmode=4 Then mmode=3 Menureverse 16 End If Menureverse 15 Delay BDelay Menureverse 15 Elseif Menucheck(16,TX1,TY1) = 1 Then PZ For qqq=0 To 11 onebyte=(relay(3)>>qqq) And 0x01 _D(qqq)=relaytimes(qqq)*600*onebyte Next If mmode=0 Then mmode=4 Elseif mmode=1 Then mmode=4 Menureverse 13 Elseif mmode=2 Then mmode=4 Menureverse 14 Elseif mmode=3 Then mmode=4 Menureverse 15 Elseif mmode=4 Then mmode=0 End If Menureverse 16 Delay BDelay Elseif Menucheck(17,TX1,TY1) = 1 Then PZ relaysON=1 Menureverse 17 Delay BDelay TurnRelaysON mmode-1 Elseif Menucheck(18,TX1,TY1) = 1 Then PZ Menureverse 18 Delay BDelay Menureverse 18 If mmode=0 Then Elseif mmode=1 Then Menureverse 13 Elseif mmode=2 Then Menureverse 14 Elseif mmode=3 Then Menureverse 15 Elseif mmode=4 Then Menureverse 16 End If If relaysON=1 Then Menureverse 17 End If relaysON=0 turnoff mmode=0 End If Elseif mode=6 Then End If

'

Return End

Sub CurrentTime(cc As Byte) Dim dhr As Byte sec=Time(0) min=Time(1) hr=Time(2) date=Time(3) day=Time(4) month=Time(5) year=Time(6) sec=Bcd2bin(sec) min=Bcd2bin(min) hr=Bcd2bin(hr) date=Bcd2bin(date) day=Bcd2bin(day) month=Bcd2bin(month) year=Bcd2bin(year) ' Timeset 6, Bin2bcd(6) Font 7,0 Style 0,0,0 'Debug Dec sec, "L",Dec sec2 , cr CalcDay

If (hr <> hr2) Or (cc=1) Then Glocate 150,10 If hr > 12 Then Dprint "PM" Else Dprint "AM" End If Glocate 10,10 If hr>12 Then dhr=hr-12 Elseif hr=0 Then dhr=12 Else dhr=hr End If Dprint Dp(dhr,2,1), ":" End If If min <> min2 Or cc=1 Then Glocate 60,10 Dprint Dp(min,2,1),":" End If If sec <> sec2 Or cc=1 Then Glocate 110,10 Dprint Dp(sec,2,1) Debug Dec prog(0).bit4 If AUTO.bit0=1 Then CheckDate 0 End If If AUTO.bit1=1 Then CheckDate 1 End If If AUTO.bit2=1 Then CheckDate 2 End If If AUTO.bit3=1 Then CheckDate 3 End If ' ' ' ' ' ' ' ' ' ' ' If mode=0 Then Locate 17,3 Print "1 2 3 4 5 6 7 8 9 10 12" If relay1 = 1 Then Circlefill 145,40,5 If relay2 = 1 Then Circlefill 160,40,5 If relay3 = 1 Then Circlefill 174,40,5 If relay4 = 1 Then Circlefill 189,40,5 If relay5 = 1 Then Circlefill 204,40,5 If relay6 = 1 Then Circlefill 219,40,5 If relay7 = 1 Then Circlefill 234,40,5

'

' ' ' ' ' ' ' '

If relay8 = 1 Then Circlefill 249,40,5 If relay9 = 1 Then Circlefill 264,40,5 If relay10 = 1 Then Circlefill 279,40,5 If relay11 = 1 Then Circlefill 294,40,5 If relay12 = 1 Then Circlefill 310,40,5 End If

End If Waitdraw ' Glocate 10,40 If date2 <> date Or month2 <> month Or year2 <> year Or cc=1 Then Font 3,3 Glocate 190,10 Dprint " " Glocate 190,10 Dprint Dec month, "/",Dec date,"/200", Dec year Glocate 275,10 Select Case day Case 0 Dprint "Sun" Case 1 Dprint "Mon" Case 2 Dprint "Tue" Case 3 Dprint "Wed" Case 4 Dprint "Thu" Case 5 Dprint "Fri" Case 6 Dprint "Sat" End Select End If sec2=sec min2=min hr2=hr date2=date month2=month year2=year End Sub ' Calculate day Sub CalcDay() Dim tmp1 As Integer Dim tmp2 As Integer Dim dyear As Integer dyear= year+2000 tmp1=year2 MOD 10 tmp2=year MOD 100 tmp2=tmp2-tmp1 tmp2=tmp2 MOD 10 tmp2=tmp2+tmp1 tmp2=tmp2+Floor (tmp2/4) Select Case month Case 1 tmp2=tmp2+6 Case 2,3,11 tmp2=tmp2+2 Case 4,7 tmp2=tmp2+5 Case 6 tmp2=tmp2+3 Case 8 tmp2=tmp2+1 Case 9,12 tmp2=tmp2+4 Case 10 tmp2=tmp2+6 End Select

day=(date+tmp2) MOD 7

End Sub Sub showbuttons() Waitdraw If prog(programtype).bit0 = 1 Then Menureverse 0 If prog(programtype).bit1 = 1 Then Menureverse 1 If prog(programtype).bit2= 1 Then Menureverse 2 If prog(programtype).bit3= 1 Then Menureverse 3 If prog(programtype).bit4= 1 Then Menureverse 4 If prog(programtype).bit5= 1 Then Menureverse 5 If prog(programtype).bit6= 1 Then Menureverse 6 If relay(programtype).bit0 = 1 Then Menureverse 7 If relay(programtype).bit1 = 1 Then Menureverse 8 If relay(programtype).bit2 = 1 Then Menureverse 9 If relay(programtype).bit3 = 1 Then Menureverse 10 If relay(programtype).bit4 = 1 Then Menureverse 11 If relay(programtype).bit5 = 1 Then Menureverse 12 If relay(programtype).bit6 = 1 Then Menureverse 13 If relay(programtype).bit7 = 1 Then Menureverse 14 If relay(programtype).bit8 = 1 Then Menureverse 15 If relay(programtype).bit9 = 1 Then Menureverse 16 If relay(programtype).bit10 = 1 Then Menureverse 17 If relay(programtype).bit11= 1 Then Menureverse 18

End Sub Sub ProgramTime() Dim phr As Byte Waitdraw Font 0,0 Style 0,0,0 Glocate 5,150 Dprint "Turn ON at:" If ProgramHour(programtype)>23 Then ProgramHour(programtype)=3 If ProgramMin(programtype)>59 Then ProgramMin(programtype)=59 If ProgramHour(programtype)=12 Then Dprint "PM " phr=12 Elseif ProgramHour(programtype)>12 Then Dprint "PM " phr=ProgramHour(programtype)-12 Else If ProgramHour(programtype)=0 Then phr=12 Else phr=ProgramHour(programtype) End If Dprint "AM " End If ' If phr = 0 Then ' Dprint "12" ' Else If phr<10 Then Dprint "0" Dprint Dec phr,":" ' End If If ProgramMin(programtype)<10 Then Dprint "0" Dprint Dec ProgramMin(programtype) End Sub Sub showrelaytimes(relaynum As Byte) Waitdraw Font 3,0 Style 0,0,0 Color 0

Boxfill 34,58,84,118,0 Color 1 Glocate 50,93 ' Dprint Dec " " ' Glocate 50,93 Dprint Dec relaynum+1 ' Glocate 180,82 ' Dprint Dec " " Color 0 Boxfill 156,60,242,114,0 Color 1 Glocate 180,82 Dprint Dec relaytimes(relaynum) End Sub Sub TurnRelaysON(uu As Byte) For qqq=0 To 11 onebyte=(relay(uu)>>qqq) And 0x01 _D(qqq)=relaytimes(qqq)*600*onebyte Next _M(0)=1 End Sub Sub CheckDate(pnum As Byte) ' Debug "program type: ", Dec pnum," prog sunday bit", Dec prog(pnum).bit6 If day = 0 And prog(pnum).bit0 = 1 Then If ProgramHour(pnum)=hr And ProgramMin(pnum)=min Then TurnRelaysON pnum End If Elseif day = 1 And prog(pnum).bit1 = 1 Then If ProgramHour(pnum)=hr And ProgramMin(pnum)=min Then TurnRelaysON pnum End If Elseif day = 2 And prog(pnum).bit2 = 1 Then If ProgramHour(pnum)=hr And ProgramMin(pnum)=min Then TurnRelaysON pnum End If Elseif day = 3 And prog(pnum).bit3 = 1 Then If ProgramHour(pnum)=hr And ProgramMin(pnum)=min Then TurnRelaysON pnum End If Elseif day = 4 And prog(pnum).bit4 = 1 Then If ProgramHour(pnum)=hr And ProgramMin(pnum)=min Then TurnRelaysON pnum End If Elseif day = 5 And prog(pnum).bit5 = 1 Then If ProgramHour(pnum)=hr And ProgramMin(pnum)=min Then TurnRelaysON pnum End If Elseif day = 6 And prog(pnum).bit6 = 1 Then If ProgramHour(pnum)=hr And ProgramMin(pnum)=min Then TurnRelaysON pnum End If End If End Sub Sub ManualON(mnum As Byte) If mm(mnum)=0 Then _M(mnum)=1 Else _M(mnum)=0 _T(mnum)=1 End If mm(mnum)=mm(mnum) Xor 1 End Sub Sub DisplayMTimes() Dim countd As Byte Waitdraw

Font 0,0 For countd=0 To 5 Glocate 5+countd*44,50 disa(countd,0)=_T(countd)/600 disa(countd,1)=_T(countd)/10 - disa(countd,0)*60 Dprint Dp (disa(countd,0),2,1), ":" Dprint Dp(disa(countd,1),2,1) Next For countd=6 To 11 Glocate 5+((countd-6)*44),120 disa(countd,0)=_T(countd)/600 disa(countd,1)=_T(countd)/10 - disa(countd,0)*60 Dprint Dp (disa(countd,0),2,1), ":" Dprint Dp(disa(countd,1),2,1) Next End Sub Sub TurnOFF() For qqq=0 To 11 _M(qqq)=0 _T(qqq)=1 mm(qqq)=0 Next End Sub Sub MAINMENU() Font 4,1 Style 3,0,0 Menuset 0,2,30,150,132,188 Menutitle 0,7,11,"Setup Time" Menuset 1,2,182,148,286,186 Menutitle 1,18,11,"Schedule" Menuset 2,2,234,98,266,130 Menutitle 2,11,8,"+" Menuset 3,2,276,98,308,132 Menutitle 3,11,9,"-" Font 1,1 Glocate 242,74 GPRINT "Contrast" Font 3,1 Menuset 4,2,28,48,136,68 Menutitle 4,7,2,"Prog 1 Auto" Menuset 5,2,28,72,138,92 Menutitle 5,6,2,"Prog 2 Auto" Menuset 6,2,28,96,138,116 Menutitle 6,6,2,"Prog 3 Auto" Menuset 7,2,28,122,138,142 Menutitle 7,6,2,"Prog 4 Auto" Font 4,1 Menuset 8,2,30,194,132,230 Menutitle 8,11,10,"Manual" Menuset 9,2,182,192,286,230 Menutitle 9,16,11,"ALL OFF" Glocate 150,56 GPRINT "Zedomax" Glocate 150,72 GPRINT "Sprinkler" Glocate 150,88 GPRINT "Program" Font 4,0 Style 0,0,0 End Sub Sub SETUPTIME() Font 4,1 Style 3,0,0 Menuset 0,2,8,114,48,152 Menutitle 0,15,11,"+" Menuset 1,2,56,114,96,152 Menutitle 1,15,11,"-" Glocate 34,90 GPRINT "Hour" Menuset 2,2,8,182,46,220 Menutitle 2,14,11,"+" Menuset 3,2,54,182,96,220 Menutitle 3,16,11,"-" Glocate 24,156 GPRINT "Minute" Menuset 4,2,108,116,148,152 Menutitle 4,15,10,"+"

Menuset 5,2,156,116,194,152 Menutitle 5,14,10,"-" Menuset 6,2,108,180,148,220 Menutitle 6,15,12,"+" Menuset 7,2,156,178,196,218 Menutitle 7,15,12,"-" Glocate 124,92 GPRINT "Month" Glocate 132,156 GPRINT "Date" Menuset 8,2,208,196,319,239 Menutitle 8,13,13,"Main Menu" Font 4,0 Style 0,0,0 End Sub Sub SCHEDULEMENU() Font 4,1 Style 3,0,0 Menuset 0,2,14,82,118,132 Menutitle 0,13,17,"Program 1" Menuset 1,2,130,82,224,132 Menutitle 1,6,17,"Program 2" Menuset 2,2,14,144,118,194 Menutitle 2,11,17,"Program 3" Menuset 3,2,130,144,224,194 Menutitle 3,6,17,"Program 4" Menuset 4,2,204,200,310,239 Menutitle 4,6,11,"MAIN MENU" Font 0,0 Style 0,0,0 Menuset 5,2,236,82,310,192 Font 4,0 Style 3,0,0 Glocate 250,100 GPRINT "Relay " Glocate 250,116 GPRINT "Time " Glocate 250,132 GPRINT "Setup" Style 0,0,0 End Sub Sub PROGRAMMENU() Font 0,1 Style 3,0,0 Menuset 0,2,0,38,38,74 Menutitle 0,8,10,"Mon" Menuset 1,2,46,38,84,74 Menutitle 1,8,10,"Tue" Menuset 2,2,92,38,130,74 Menutitle 2,8,10,"Wed" Menuset 3,2,140,38,178,74 Menutitle 3,8,10,"Thu" Menuset 4,2,186,38,224,74 Menutitle 4,8,10,"Fri" Menuset 5,2,230,38,268,74 Menutitle 5,8,10,"Sat" Menuset 6,2,274,38,319,74 Menutitle 6,12,10,"Sun" Menuset 7,2,0,112,22,134 Menutitle 7,7,3,"1" Menuset 8,2,24,112,46,134 Menutitle 8,7,3,"2" Menuset 9,2,48,112,70,134 Menutitle 9,7,3,"3" Menuset 10,2,74,112,96,134 Menutitle 10,7,3,"4" Menuset 11,2,98,112,122,134 Menutitle 11,8,3,"5" Menuset 12,2,126,112,148,134 Menutitle 12,7,3,"6" Menuset 13,2,150,112,174,134 Menutitle 13,8,3,"7" Menuset 14,2,178,112,200,134 Menutitle 14,7,3,"8" Menuset 15,2,204,112,224,134 Menutitle 15,6,3,"9" Menuset 16,2,228,112,256,134 Menutitle 16,7,3,"10" Menuset 17,2,258,114,288,134 Menutitle 17,7,2,"11" Menuset 18,2,290,114,319,132

Menutitle 18,7,1,"12" Font 4,1 Menuset 19,2,222,194,319,239 Menutitle 19,6,14,"Main Menu" Font 0,1 Glocate 8,90 GPRINT "Relay Number" Font 4,1 Menuset 20,2,122,194,218,239 Menutitle 20,4,14,"Prev. Menu" Font 0,1 Menuset 21,2,156,144,186,168 Menutitle 21,11,4,"+" Menuset 22,2,190,144,220,168 Menutitle 22,11,4,"-" Menuset 23,2,244,144,274,168 Menutitle 23,11,4,"+" Menuset 24,2,278,144,308,168 Menutitle 24,11,4,"-" Glocate 176,172 GPRINT "Hour" Glocate 266,174 GPRINT "Min" Font 4,0 Style 0,0,0 End Sub Sub STATUSMENU() Font 4,1 Style 3,0,0 Menuset 0,2,5,75,40,105 Menutitle 0,15,7,"1" Menuset 1,2,50,75,80,105 Menutitle 1,10,7,"2" Menuset 2,2,90,75,120,105 Menutitle 2,10,7,"3" Menuset 3,2,130,75,160,105 Menutitle 3,10,7,"4" Menuset 4,2,170,75,200,105 Menutitle 4,10,7,"5" Menuset 5,2,210,75,245,105 Menutitle 5,13,7,"6" Menuset 6,2,6,150,40,182 Menutitle 6,12,8,"7" Menuset 7,2,50,150,80,180 Menutitle 7,10,7,"8" Menuset 8,2,90,150,120,180 Menutitle 8,10,7,"9" Menuset 9,2,130,150,160,180 Menutitle 9,7,7,"10" Menuset 10,2,170,150,200,180 Menutitle 10,10,7,"11" Menuset 11,2,210,150,245,185 Menutitle 11,10,9,"12" Menuset 12,2,212,188,310,239 Menutitle 12,6,17,"Main Menu" Font 0,1 Menuset 13,2,10,195,45,230 Menutitle 13,10,9,"P1" Menuset 14,2,55,195,90,230 Menutitle 14,10,9,"P2" Menuset 15,2,100,195,135,230 Menutitle 15,10,9,"P3" Menuset 16,2,145,195,180,230 Menutitle 16,10,9,"P4" Menuset 17,2,270,85,305,110 Menutitle 17,10,4,"ON" Menuset 18,2,270,120,305,145 Menutitle 18,7,4,"OFF" Font 4,0 Style 0,0,0 End Sub Sub RELAYMENU() Font 7,1 Style 3,0,0 Menuset 0,2,142,126,192,170 Menutitle 0,17,10,"+" Menuset 1,2,200,126,248,170 Menutitle 1,17,10,"-" ' Linestyle Dotsize 0,0 Color 1

Box 154,58,244,116 Font 4,1 Menuset 2,2,214,190,311,235 Menutitle 2,6,14,"Main Menu" Menuset 3,2,114,190,210,235 Menutitle 3,5,14,"Prev. Menu" Font 3,1 Glocate 254,96 GPRINT "Minutes" Font 5,1 Glocate 35,60 GPRINT "Relay #" Box 30,80,85,120 Font 7,1 Menuset 4,2,8,126,54,170 Menutitle 4,15,10,"+" Menuset 5,2,60,126,106,170 Menutitle 5,16,10,"-" Font 3,1 Menuset 6,2,260,128,310,170 Menutitle 6,8,13,"zero" Font 4,0 Linestyle 0 Style 0,0,0 End Sub

Zedomax DIY105 - Zedomax Party Light -How to Make a computer controlled Party Light in 90 seconds!
6

Today, I was thinking about how I can turn a household bulb into a party light by connecting an embedded computer for my next party in my garage.

Here's a video of Party Light Assembly & in Action on YouTube

Here's a video of programming the sucker on YouTube

41

Parts List
$5

1(or more) Household bulb + Light


Available at Home Depot

1 CB280 Start Kit 1 SSR4 Board

Available at Comfile Technology

$115 $19

Estimated Time to Assemble: 90 seconds Estimated Time to Program: 90 seconds

1 12

Connections

(SSR4 Board Close-up)

(2 wires to the study board, 1 to port P0 and the other to 5V) .

42

CODE Analysis...

Now as you can see below, I made a very simple code of about 7 lines of BASIC code. You can get more complicated if you want to. But basically I used Out() system command to output logic High and Low to port P0. Then I used Delay command to approximately delay 500 msec before setting the output to high or low. You can simply copy and paste the code to your CublocStudio. BASIC Source Code: [relay001.cul]
Const Device = CB280 Do Out 0,1 Delay 500 Out 0,0 Delay 500 Loop

43

Taking it Further...

Now since the SSR4 board supports up to 4 AC devices up to 250VAC, you are only limited to your imagination on how many household lights you can control. This probably can be applied to home automation, club scenes, robotics, and more! I think if you own a small night club, you can definitely make a use out of this type of DIY... Paty Light Part II

Zedomax DIY106 - Zedomax Party Light II- How to Make a computer controlled Party Light Part II
7

Okay, last time I made a computer controlled party light in 90 seconds but I ran into some problems. The party light was an experiment and I needed something that would be more realistic. Something that has isolation to protect against electrical surges and what not that could cause pre-mature device failure and all that jazz. So I just took the idea and went a little deeper.

Here's a video of Party Light II in Action on YouTube

Parts List
Available at Home Depot

6(or more) Clip-on bulb thingee

$30 $1 $129

1 Din-rail

Available at www.din-rail.com

1 CuSB-22R

Available at cubloc.com

Estimated Time to Assemble: 1 hour Estimated Time to Program: 20 minutes (or none if you use my source code)

Connections

(Wiring, notice I have a yellow wire between label COM and L)

(Sticking it on the DIN rail w/ the clip on bulbs)

(The CuSB has a DIN-rail mount, so you can just stick it on the DIN-rail) Here's a simple diagram for connections:

. (When a relay turn On, the blue line gets connected w/ the red line via the green line)

(party time~)

44

Program Source...

You can simply copy and paste the code to your CublocStudio and then download to your CuSB PLC. You can play around with it by changing the numbers of For...Next loops and the delay times of sub functions.

45

Source Code

[relay002.cul]
Const Device = CB280 Dim a As Byte Do For a=0 To 2 Program1 100 Next For a=0 To 2 Program2 Next For a=0 To 2 Program2B Next For a=0 To 2 Program3 Next For a=0 To 2 Program4 100 Next For a=0 To 5 Program4 50 Next For a=0 To 5 Program4 40 Next For a=0 To 10 Program1 30 Next

Loop End Sub Program1(d As Integer) one Delay d two Delay d one Delay d two Delay d one Delay d two Delay d one Delay d End Sub Sub Program2() Dim B As Byte Out 42,1 Out 43,1

Out 44,1 Out 45,1 Out 46,1 Out 47,1 For B=41 To 47 Out B,(Outstat(B) Xor 1) Delay 100 Next For B=47 To 42 Step -1 Out B,(Outstat(B) Xor 1) Delay 100 Next End Sub Sub Program2B() Dim B As Byte Out 42,1 Out 43,1 Out 44,1 Out 45,1 Out 46,1 Out 47,1 For B=47 To 42 Step -1 Out B,(Outstat(B) Xor 1) Delay 100 Next For B=41 To 47 Out B,(Outstat(B) Xor 1) Delay 100 Next End Sub Sub Program3() oneA Delay 200 twoA Delay 400 oneA Delay 200 twoA Delay 400 oneA Delay 200 twoA Delay 400 oneA Delay 200 twoA End Sub Sub Program4(d As integer) one Delay d Out 42,0 Out 43,0 Out 44,0 Delay d one Delay d Out 42,0 Out 43,0 Out 44,0 Delay d one Delay d Out 42,0 Out 43,0 Out 44,0 Delay d one Delay d Out 42,0 Out 43,0 Out 44,0 Delay d two Delay d Out 45,0

Out 46,0 Out 47,0 Delay d two Delay d Out 45,0 Out 46,0 Out 47,0 Delay d two Delay d Out 45,0 Out 46,0 Out 47,0 Delay d two Delay d Out 45,0 Out 46,0 Out 47,0 Delay d

End Sub Sub one() Out 42,1 Out 43,1 Out 44,1 Out 45,0 Out 46,0 Out 47,0 End Sub Sub oneA() Out 42,1 Out 43,0 Out 44,1 Out 45,0 Out 46,1 Out 47,0 End Sub Sub twoA() Out 42,0 Out 43,1 Out 44,0 Out 45,1 Out 46,0 Out 47,1 End Sub Sub two() Out 42,0 Out 43,0 Out 44,0 Out 45,1 Out 46,1 Out 47,1 End Sub

46

Taking it Further...

The idea here is very simple, that we can make a party light for this weekend's labor day barbeque w/ friends while my boss has gone to a meeting... OR you can use this simple lighting for your next big show, retail display, clothing store, small nightclub or bar, bottom of your car (use DC lights), office, open-house, parties, holloween, etc...etc... Anyways, we will make some new things next time I get a chance...

Zedomax DIY107 - Zedomax Wall Clock - How to Make a wall clock w/ temperature monitor from scratch!

Okay, today I am going to show you how to make Zedomax Wall Clock that I use to keep track of current time, date, and the most important, the temperature in fahrenheit and celcius. I am very sensitive to the temperature, especially when it gets hot, I gotta turn on the fans...

Here's a video of Wall Clock in Actionon YouTube

Parts List 1 Din-rail


Available at www.din-rail.com

$1 $141 $34 ea $19 $5

1 CB290 Start Kit 3 CSG-4M 1 CSG-4S 1 DS1620

Available at cubloc.com

Available at mouser.com, digikey.com

Estimated Time to Assemble: 30 minutes Estimated Time to Program: 1 hour (or none if you use my source code)

47

Connections

(Time is 10:23:08 AM)

(Date is September 1st)

(Current temperature is 21.50 degrees celcius)

(Current temperature is 70.69 degrees fahrenheit)

(ZOOMed) Solder on the DS1620 chip onto the protoboard as shown above.

You can solder 3 pins, DQ, CLK, and RST to the chip and simply connect to the IDS connectors or the termnial connectors w/ label P19, P20, and P21. For VDD and GND, solder VDD to 5V and GND to ground on the proto-board. For the CSG-4S, connect to the upper right connector and the CSG-4M to the lower right connector like this:

You can connect the 3 CSG-4Ms in series like this:

Now set the ID of the CSG-4Ms to 0, 1, and 2, respectively, using the DIP switches on the back.

(picture of CSG-4S, CSG-4M should be identical)

48

Program Source...

You can simply copy and paste the code to your CublocStudio and then download to your CuSB PLC. In the beginning of the source, you will see the following lines: ' Timeset 0,&h00 'second

' Timeset 1,&h28 'Minute ' Timeset 2,0x12 'Hour ' Timeset 3,0x01 'Date ' Timeset 4,0x01 'Day ' Timeset 5,0x09 'Month ' Timeset 6,06 'Year You can change this values to set the time at the beginning.

Download BASIC Source Code

49

Taking it Further...

You can add some party light to this using some relays like DIY105 so you know when it's lunch time. OR you can add a buzzer for loud sound for lunch time like the alarm system in DIY100. The picture shows an XPORT module on it which basically allows me to download new programs to this module via ethernet. Yes, you can do that but I will get into that next time. In the meanwhile, you can add some other features and see if you can make the coolest geeky Wall Clock in the world and let me know if you do because I am interested.
If you have some cool Wall Clocks that don't look like wall clocks, please send me~ :)

Zedomax DIY108 - Zedomax Alarm System II - How to Make an alarm system in 3 minutes! (Part II) - Add a motion sensor!
9

Here's a video of Zedomax Alarm System II in Action on YouTube

50

Parts List
$27

1 RadioShack Motion-sensing Door Chime/Alarm Other parts from Zedomax Alarm System Part I Estimated Time to Assemble: 3 minutes Estimated Time to Program:

10 minutes (or none if you use my source code)

The other day I was walking through RadioShack and found this neat little Motion-sensing Door Chime/Alarm. Since I already had an alarm system, I decided I could simply add a motion-sensor to my existing alarm system.

51

Connections

1) First disassemble the motion-sensor like shown in above picture.

2) Now disconnect the speaker wires, we don't need the speaker on the motion sensor since we already have one on our alarm system.

3) Solder 2 wires to the speaker wires. Make sure to mark one of the wires as ground for later. I used a black tape to mark it.

4) When you measure the speaker outputs, you should get around 8V DC, we will need this information in order to not burn up our CB280 module.

5) You can take the wires outside of the casing through the battery connectors.

6) Assemble your motion-sensor now like shown above.

7) Now you have a motion sensor w/ 2 wires you can use to sense motion!

8) Connect the the Positive wire of the motion sensor to the middle of a 3804 TR. Connect the GND of motion sensor to GND of the study board. Now you can connect 5V of the study board to the right side of the 3904 TR and the P21 of the study board to the left side of the 3904 TR as shown in the above picture. Connect a LED Output to P21 to check that motion sensor is working and the CUBLOC module will receive correct digital signals.

Now check that your motion sensor is working by turning the motion sensor to "Chime" and try flickering your hands in front of it. The LED on the motion sensor and the study board should go off together in harmony. Now simply unzip and download this program using CublocStudio: HomeAutomation002.zip

You should get a nice Motion line added to your existing alarm system. Try turning On your alarm system, the password is 1234. Now make some movements on the motion sensor to set it off. The alarm system will go off and the only way to turn it off is by entering your password again. Press the CNCL button if you mess up your password.

52

Program Source...

(Bold for added code)


Const Device = CB280 #define MyPass 1234 Set Pad 0,1,10

Const Byte KEY_TABLE=(0,0,14,16,0,15,0,0,0,0,13,9,8,7,0,0,0,0,12,6,5,4,0,0,0,0,11,3,2,1) 'Key table if Keypad inserted backwards to the Keypad Controller 'Const Byte KEY_TABLE=(0,0,1,4,7,10,0,0,0,0,2,5,8,11,0,0,0,0,3,6,9,12,0,0,0,0,13,14,15,16) Dim X As Byte 'Status of Alarm Dim AlarmON As Byte

Dim AlarmStayON As Byte


'Status of Door Dim Door As Byte

'Status of Motion Sensor Dim Motion As Byte


Dim Password As Long Door=0

Motion=0
Password=0 AlarmON=0

AlarmStayON=0
Input 0 Input 1 Input 2 Input 3 'Set port P5 to output Output 5 'Set Magnetic Switch to input Input 20 On INT0 Gosub GETINT Set int0 2

Input 21 On INT1 Gosub GETINT_M Set int1 2


On Pad Gosub PAD_RTN Set Ladder Off Set Display 2,0,0,128 Cls Delay 100 Csroff Locate 0,0 Print "Zedomax Alarm System"

'Add motion sensor LCD commands Locate 0,1 Print "Motion: " If In(21)=1 Then Print "movement"

Else Print "none" End If

Locate 0,2 Print "Door is: " If In(20)=1 Then Print "open" Else Print "closed" End If If AlarmON=1 Then Locate 0,3 Print "Alarm Status is ON" Else Locate 0,3 Print "Alarm Status is OFF" End If Do

If (AlarmON=1 And Door=1) Or (AlarmON=1 And Motion=1) Then AlarmStayON=1 End If If AlarmStayON=1 Then Alarm End If
Loop GETINT: Door=In(20) Debug "Door: ",Dec Door,Cr Alarm If Door=0 Then Locate 9,2 Print "closed " Debug "door closed",Cr Else Locate 9,2 Print "open " Debug "door open",Cr End If

Delay 500 Return

GETINT_M: Motion=In(21) Debug "Motion: ",Dec Motion,Cr

'Add motion sensor LCD commands If Motion=0 Then Locate 8,1 Print "none " Else Locate 8,1 Print "movement " End If Delay 200 Return

PAD_RTN: Peep X=Getpad(1) If X>29 Then Return X=KEY_TABLE(X) Debug "Key Pressed: ", Dec X,Cr If X < 10 Then Password=Password*10+X If Password > 9999 Then Password=X Debug "Password: ", Dec Password,Cr If Password = MyPass Then AlarmON=AlarmON Xor 1 If AlarmON=1 Then Locate 0,3 Print "Alarm Status is ON " Else Locate 0,3 Print "Alarm Status is OFF"

AlarmStayON=0
End If End If 'If ENTR pressed Elseif X=11 Then 'If CNCL pressed Elseif X=15 Then Password=0 End If Return End Sub Alarm() Out 5,1 Delay 100 Out 5,0

Delay 100 End Sub Sub Peep() Out 5,1 Delay 5 Out 5,0 Delay 5 End Sub

53

Taking it Further...

Now you can take it further, maybe add a SMS messaging capabilities when the alarm goes off, or hack a wireless motion-sensor to do the same thing. You can always build from scratch but sometimes I feel you can simply hack stuff from RadioShack and save yourself the trouble.

Zedomax DIY109 - Zedomax Digital Thermometer - How to Build a digital thermometer in 1 minute!
10

Here's a video of building a digital Thermometer in 1 min on YouTube

Here's a video of Zedomax digital Thermometer in Action on YouTube

54

Parts List

1 CB280 Start Kit 1 CLCD420B 1 DS1620 (available at mouser.com or digikey.com too) available at cubloc.com Estimated Time to Assemble: 1 minutes Estimated Time to Program: zero (source code provided)

Okay, it seems like the only class I really enjoyed in college was the embedded computer class. All the other circuit classes and computer language classes bore the hell out of me because they was no actual product. With embedded computers, you actually physically get to see stuff and that's what I liked about it. Well I started w/ the Motorola MC68 series microcontrollers and it took me almost a week to make a digital thermometer. I had to make everything from scratch. It was still interesting because I made something physical and it worked! Anyways, now I am glad I can do the same thing except it only takes me 1 minute! Not because I got smarter but mostly because I've done this thousand times now, but I think anyone should be able to accomplish this in 1 minute if you follow these directions. :)

55

Connections

Just follow the above picture exactly in less than 1 minute and you have the following source code to download and make this thing work! diy109.zip

56

Taking it Further...

Okay, now you have a 1 minute guide to making a digital thermometer. Go to your college professor and show him how you can make one in 1 minute... maybe he will give you some extra credit...

57

Program Source...

' DS1620 Temperature Sensor App v.0.0.1 ' v0.0.1 - Displays upto 2 decimals ' by using DS1620's precise mode Const Device=cb280 ' Set Pin numbers! ' Set DQ,CLK,RST pins 'Connect P24 to RST of DS1620 'Connect P25 to CLK of DS1620 'Connect P26 to DQ of DS1620 #define RST 24 #define CLK 25 #define DQ 26 Set Ladder Off

Dim ReturnedTemp As Single, TempF As Single, TempC As Single 'Floating Point variables for storing temperature Dim COUNT_REMAIN As Single, COUNT_PER_C As Single 'Floating Point variables for calculations Dim tmp As Single 'Temporary variable for Floating Point Dim TempString As String *6 Dim TempFString As String * 6 Dim TempCString As String * 6 Set Display 2,0,0,128 'Erase screen Cls Delay 100 Csroff Locate 2,0 Print "Zedomax Digital" Locate 5,1 Print "Thermometer" Locate 0,2 Print "Fahrenheit: " Locate 0,3 Print "Celcius: " DS1620Init 'On timer(5) Gosub MAINPROCESS 'Timer Interrupt every 500msec! Do DS1620 Loop 'MAINPROCESS: 'Return End

Sub DS1620Init() Output RST Output CLK Output DQ 'Send Initialization to DS1620 Out RST, 1 Shiftout CLK,DQ,0,0x0C,8 Shiftout CLK,DQ,0,0x02,8 Out RST, 0 'Start DS1620 Temperature Conversion! Out RST, 1 Shiftout CLK,DQ,0,0xEE,8 Out RST, 0 End Sub Sub DS1620() '------Read Temp-----------------------------Out RST,1 Shiftout CLK,DQ,0,0xAA,8 ReturnedTemp=Shiftin(CLK,DQ,0,9) ReturnedTemp=ReturnedTemp/2 Out RST,0 Out RST,1 Shiftout CLK,DQ,0,0xA0,8 COUNT_REMAIN=Shiftin(CLK,DQ,0,9) Out RST,0 Out RST,1 Shiftout CLK,DQ,0,0xA9,8 COUNT_PER_C=Shiftin(CLK,DQ,0,9) Out RST,0 '------Precision Formula (According to DS1620 Data Sheet) tmp=(COUNT_PER_C-COUNT_REMAIN) tmp=tmp/COUNT_PER_C If tmp>0 Then TempC=ReturnedTemp-0.25 TempC=TempC+tmp Else TempC=ReturnedTemp End If 'Change from Celcius to Fahrenheit! TempF=TempC*1.8 TempF=TempF+32 'Convert floating point value to string and set the number of decimals TempString=Float ReturnedTemp TempFString=Float TempF TempCString=Float TempC TempString=Left(TempString,4) TempFString=Left(TempFString,5) TempCString=Left(TempCString,5) 'Output to LCD! Locate 12,2 Print TempFString Locate 12,3 Print TempCString ' Locate 0,2 ' Print TempString, " Deg C (w/o precision)", Cr 'Print to debug screen! 'Debug "Current Temperature in is ", Cr,TempFString, " Deg F ", Cr 'Debug TempCString, " Deg C", Cr 'Debug TempString, " Deg C (without precision)", Cr End Sub

Zedomax DIY110 - Zedomax Digital Thermometer II - How to Make a Ethernet Temperature Monitor
11

Here's a video of ethernet temperature monitor in Action on YouTube

58

Parts List

1 XPORT 1 XPORT Dongle available at cubloc.com Parts from Zedomax Digital Thermometer Estimated Time to Assemble: 1 minute Estimated Time to Program: zero (source code provided) Okay you've built the digital thermometer but you ran out of ideas and didn't know what to do with it. Well if you wanted to, you could add a Lantronix XPORT ethernet serial device to the serial channel and monitor temperature over the ethernet.

1) Solder the XPORT to the XPORT Dongle, it should fit right in. 2) We are going to have to hack the study board so the XPORT will power up on serial channel 1. So unscrew the 4 screws on the study board and disassemble it like this:

3) Okay good, once youve annihilated the study board as shown above, simply flip the Channel 1 Board and Solder (yes, you need to solder) a wire as shown here. You are simply connecting 5V to pin 9 of the Channel 1.

4)Okay, now place it nicely back in place and screw everything back in.

Now when you connect XPORT to Channel 1 serial port (YES, the Bottom one!), you should see XPORT lighting up.

You should also connect 2 wires from RS232C TX and RX CB280 TX and RX as shown below:

Download the new CUBLOC DS1620 program here: DS1620Ethernet.zip Now you should be ready, make sure your XPORT is blinking and open up your Lantronix DeviceInstaller. Download Lantronix DeviceInstaller

Select your XPORT and then go into Web Configuration and set the baud rate to 115200 bps and press "OK", then press "Apply Settings" on the left tab. The XPORT should reset and you should be ready for some ethernet temp monitoring. Download Zedomax Temperature Monitor Program w/ Visual Basic source code Run ZedomaxTempMonitor.exe and enter the IP address of your XPORT and press the "Connect" button like this:

You should get a "Connected!" message if your XPORT is on the network.

Now press "Start Monitoring Temp" and wala, you should see the same temperature on the program as your LCD screen.

59

Taking it Further...

Okay, this is the start of simple ethernet monitoring of temperature. If you had a static IP address for your XPORT, you can monitor temperature of your room from New York, LA, San Francisco, Paris, etc...etc... You could probably take this and take it further by modifying the Basic source codes. A Visual Basic source code is included so you can modify buttons, protocol, etc...etc... You can use the XPORT and XPORT Dongle very easily to any microcontroller that has a serial port. Since it's all serial, you are only limited to your imagination of embedded ethernet creations... Next time, let's see if we can make a party light enabled via ethernet...

Zedomax DIY111 - Zedomax User Interface Skeleton - How to Make a User Interface in 5 minutes!
12

Video of Zedomax User Interface on YouTube

60

Parts List

1 RCABLE Connector Male 6PT 1 CB290 Start Kit 1 3x4, 4X4, or 5x4 Numerical Keypad 1 Keypad Controller available at cubloc.com Estimated Time to Assemble: 5 minutes

Okay first, you want to connect one of the 6-pin connector onto the proto board like shown above.

Then, you can solder the 6-pin connector on the back of the protoboard. Noting the 5V, GND, P0, P1, P2, and P3 on the Keypad Controller, solder the appropriate pins using thin wires.

As you can see above, the right most pin is connected to Ground and the one next to it is connected to 5V.

You can see I've soldered the other 4 pins to P0, P1, P2, and P3 as shown here.

Now clip on your Keypad Controller RCABLE to the connector you just made.

Make sure to solder the Keypad on the Keypad Controller, something like above.

Download this program and test your new user interface skeleton! Everytime you press a button, you should see the LEDs lighting up... (a little extra feature I added to demonstrate the Ladder Logic multi-tasking feature of CUBLOC)

61

Taking it Further...

Yes now you have a keypad, a LCD, and cool LEDs that go up and down whenever you press a keypad button. From here, maybe you can add some peripherals and make it something... Last time we did the alarm system which is basically using the same user interface as this one... I am thinking about some kind of space craft

Zedomax DIY 112 - Zedomax Hovercraft Version 2 Asteroid How to Build a hovercraft!
13

Okay, yesterday through the instructable, we made a simple hovercraft. Today, we are going to take it to another level by taking FOUR PC fan coolers and running the FANS at 24VDC instead of the 12V DC rating. I think they are okay up to 30VDC, well, our fans are still running Click HERE to see Video DEMO of the Hovercraft on YouTube

Click HERE to see Video DEMO of Hovercraft on YouTube

Parts List
4 Antec PC Case FANS $8 each 1 Foam Board $3

(goto Staples or Office Depot, Office Max) 1 Knife 1 DC Power source of some sort

Okay, as me and Jackie bought some foam board and some PC fans, we thought about how we are going to make it... Since the foam board is flat, we figured we needed a separate outside layer for air pressure to build inside the circle...

First, we didn't have an idea about the physics of a hovercraft, but figured it might as well be a circle. So we quickly grabbed some paper and drew a big circle like shown here:

Next, we grabbed another foam board and made the outside layer for the circle.

Next, we cut those circles...and yes I got thumbs up from Jackie...

Next we randomly decided for the fan location to be 3 inches from the center like shown here and marked it using the measuring tool...

Next, we made sure the locations were perpendicular using a paper like shown here:

Next we took part of my PC case, where it has an exact circle of a PC case fan and drew 4 circles for the fans...

When done right, looks like this:

Next, simply cut the circles, then glue the outside circle piece onto the main circle piece. Place the 4 PC fans and glue them onto the holes using a glue gun like shown here:

Make sure to keep everything air-tight like this:

Finished Hovercraft Asteroid bottom view:

Finished Hovercraft Asteroid top view: (You can simply connect all VCC together and Ground (GND) together and connect to a LAN wire (well you don't have to use LAN wire, it's the only thing I could find that was longer than 6 feet)

When you are done, hook up VCC and GND to your power supply and crank up your Power Supply to 12V, if it works well, crank upto 24V and enjoy!

This hovercraft is way more powerful than the single fan version, it almost came 1/2 inch off the ground at 22VDC like shown here:

62

Taking it Further...

Yes, next time I think we are going to somehow see if we can put a microcontroller on this hovercraft and make it move by itself...

Zedomax DIY113 - Zedomax Hovercraft Version 3 - Asteroid II How to Build a bluetooth controlled Halloween Hovercraft party light!
14

Okay, the other day we made a cool hovercraft, today we will add a bluetooth module and a embedded computer to make it spin!

See Video of Hovercraft on YouTube

Parts List
Parts from original hovercraft. (Yes, you need to make the hovercraft first...) 2 CUBLOC CB220 modules 2 CB220 Proto Boards 2 Acode-300 Bluetooth Modules 2 Pushbuttons 2 LEDs 2 I/O Cell Relays 2 5V to 3.3V regulator (for ACODE-300, I got mine off an XPORT Dongle...) 2 DC Jacks 1 9V Battery 1 AAA Battery 2 330Ohm Resistors 3 10K Resistors 1 Creativity 1 Concentation

63

HOWTO

First, you will need to make some circuits. You need make a transmitter module and a receiver module for your hovercraft. Here's what the ACODE-300 Module's pinouts look like:

You basically need to make a circuit for the ACODE-300, which we did this before with wireless LCD, you can refer to this link

You can download the full schematic here: Asteroid II Bluetooth Trasmitter & Receiver After you make the trasmitter and receiver, you should have something like this: Transmitter:

Receiver (to put on the hovercraft) :

Okay, this should take you about 1 hour for the Transmitter and 1 hour for the Receiver.

Once you are done making it, make sure to setup your ACODE-300 modules to 115200 bps and they are connecting. Before putting your ACODE-300 on your trasmitter and receiver, set them up using the software below and the ACODE Interface Board:

Insert your ACODE-300 module as shown above to the interface board. Also connect a serial cable and DC power (between 5 and 12V) to the interface board. Run the PromiWIN4.0_Setup(En).exe installer program and install Promi software, which we will use to link the two ACODE-300 wireless modules. PromiWIN4.0_Setup(En).exe Download

The default baud rate for ACODE-300 is set at 9600 bps. So Just click OK, and you should be able to see the following screen:

Now we are ready to set the device to a faster baud rate.

Change the Operation Mode to MODE3, Baud rate to 115200bps and set the device name to device 1 as shown above.

If you get the message Configuration has been applied, you are ready to go. Unplug your ACODE-300 module from the interface board and plug it back into your trasmitter.

Power ON your study board and your ACODE-300 should start blinking the LED like above every 1-2 seconds. Now take your ACODE-300 module from your receiver and plug it into the interface board and run Promi program again.

Once you are connected, change the Operation Mode to MODE1, Baud rate to 115200bps and set the device name to device 1 as shown above. After applying the above settings, Click on Connection(out) and press Search.

You should be able to find the device 1, the ACODE-300 module on the study board.

Now, select the device 1 and click on Connect. You should see both LEDs of ACODE-300 turn on continusly once you get this message:

(LEDs continuously ON) When LEDs are lit up like above, the ACODE-300 modules are connected and a straight RS232 serial connection has been established. Its as if a serial cable has been connected wirelessly. Now unplug the ACODE-300 module from the interface board and plug it back into your receiver module:

Now when you power ON both trasmitter & receiver and you should see both LEDs light ON as shown in above picture. Now open up your CUBLOC Studio and compile and download the transmitter program to the transmitter andthe receiver program to the receiver.

Click here to Download Transmitter Program Click here to Download Receiver Program

Now take your new party light to your friend's next party and start groovin! Cool Pics of transmitter fitting in my hand:

64

Taking it Further...

Well, I've built a very simple protocol, actual here's the whole code for the transmitter: Const Device = CB220 #define DEBOUNCE_RATE 10 Input 0 Input 1 On timer(DEBOUNCE_RATE) Gosub CheckKey 'Set at 200ms Opencom 1,115200,3,10,10 Dim key0 As Byte, key1 As Byte

Do Loop CheckKey:

key0 = In(0) key1 = In(1) If key0=1 And key1=1 Then Debug "Both Keys Pressed",Cr Putstr 1, "B" Elseif key0=1 Then Debug "Right Key Pressed",Cr Putstr 1, "R" Elseif key1=1 Then Debug "Left Key Pressed",Cr Putstr 1, "L" End If Return

And the code for receiver: Const Device = CB220 Output 14 Output 15 Dim Command As Byte Dim Length As Byte Opencom 1,115200,3,3,3 On Recv1 Gosub Get_Command Out 14,0 Out 15,0 Do Loop Get_Command: Length=Blen(1,0) If Length>0 Then Command=Get(1,1) If Command=Asc("L") Then Debug "Left Button Pressed",Cr Out 14,1 Delay 200 End If If Command=Asc("R") Then Out 15,1 Delay 200

Debug "Right Button Pressed",Cr End If If Command=Asc("B") Then Out 14,1 Out 15,1 Delay 200 Debug "Both Button Pressed",Cr End If End If Out 14,0 Out 15,0 Return

Basically, all I did was to limit number of receive buffer and send buffer using Opencom() to prevent case of overflow and just use three letters, L, R, and B. L is for Left, R is for right, and B is for both buttons. You could probably see that you can build much more complex code on top of this.

Here's schematic of I/O Cell Relay and ACODE Data spec sheet for reference:

I am thinking of a hover-bot next...I think I can just put some sensors and make it roam around on it's own now, no more controlling it, got to give it freedom to think on its own... :) Happy Holloween! <:)

Zedomax DIY114 - Zedomax Halloween Picketfork LED How to Make a LED Trident!
15

Click HERE to see LED Trident on YouTube

Parts List
1 Picketfork (I bought mine for a dollar at dollar store in SF) 15 LEDs (available at RadioShack) 1 CUBLOC CB220 Module (available at cubloc.com) 1 24-pin DIP socket (available at RadioShack) 1 Glue-gun or Epoxy or silicon 1 lots of wires 1 duck-tape or electrical tap 1 9V battery 1 Drill (helps, you could probably use a knife too) 1 Creativity 1 Persistence

65

HOWTO

Time to build: About 2 hours.

Okay, if you have one of those black and decker drills, you can drill some holes for the LED pretty quickly...

Okay, start by drilling 5 holes on each fork like shown above, drill through the fork, so you actually have 1 hole on each side.

When you are done, you should see something like above...

Now insert LED into the holes, making sure to note that the LONG side of the LED is on one side, which is POSITIVE, and the other is GROUND. I had to re-solder after I realize some of my LEDs were backwards... (duh~) Okay, After you put all your LEDs on the pitchfork, pat yourself on the back and go get another cup of coffee(if you haven't have coffee yet, what's wrong with you? hehe...)

Okay once you place all the LEDs on the picketfork, simple wire up the GROUND side together using wires... I found that you can splice your wire kinda like this to save time:

Well if I had the time, I would put all the wires inside the picketfork tubing...but I will just use some red electrical tape today since I gotta also make my custume... Oh yeah, make sure all the ground (the short side of LEDs) are connected together and you have a wire coming out at the bottom for connecting it later to ground...

Tape it up nice like above...

Now, hook up the positive side of LEDs using individual wires long enough to reach the bottom of the fork (not bottom of the whole pitchfork!!!)

Tape that up too... The above picture shows only one of the forks being taped, do it for the other two forks too and tape them up...(well if you know a better way, awesome! ) ) Once you've done that, you should have 15 wires for positive side of LEDs and 1 wire for ground of all LEDs...

Now, let's add a pushbutton to the bottom of the pitchfork so we don't have to leave it on all the time and waste battery, we can turn it on whenever we are poking others... Okay, just drill four holes like above and put 2 wires through the tubing so it comes out on the other side...

Next, solder on your pushbutton like shown here... (test it before soldering...) Then you can simply put some black electrical tape and voila, you have a power on/off switch.

For one of the wires, connect it to the Positive (+) of the 9V battery. The other wire, connect it to CUBLOC pin 24 (VIN). The negative (-) side of the 9V battery should be connected to CUBLOC pin 4 or pin 23 (VSS), which is ground.

This way, when the pushbutton is pressed, it should power up the CB220 module. When it's not pressed, you are saving energy, yes, earth too!

Next, I drill some hole for the battery wires to come out...

Now, take those 15 wires and put them on the CUBLOC I/O pins except P1 or pin 6... You can put them anywhere of the P0 through P15 ports... (just don't use P1, it's input only) Well when you are done, use a glue-gun or epoxy like me, as I realized DIP sockets are pain in the neck to solder and will fall apart by itself...but I used a glue-gun and it's stable as heck... You ask why I am not using any resistors? Well, first of all, we are only using a battery, second, extra parts = extra work... Well also connect the Ground from the LEDs to pin 4 or pin 23 of the CB220 (GND)...

You should end up like something above, which isn't spectacular. It's a quick hack for halloween so please don't complain... Well, the reason I made this was to make some cool LEDs on the pitchfork... I realized that I can manipulate the code to make it a pitchfork LED that can display letters and numbers!!! anyway, here's my array note sheet:

I realized by taking about 5 ms delay, I can display these characters and the rest if matter of coding...

Okay, now, going back to the project,

After you take it up, you should have something like above, which is pretty good for 2 hour hack... Oh yeah, make sure to download this program, or you can edit it for your own letters or LED flashing programs... Download Pitchfork LED Program zedomax in action:

Happy Halloween! The whole code:

Const Device = CB220

'Pitchfor 1st fork pin numbers Const Byte a = (9,11,12,13,14) 'Pitchfor 2nd fork pin numbers Const Byte b = (6,15,8,10,7) 'Pitchfor 3rd fork pin numbers Const Byte c = (0,2,5,3,4) Dim ct As Byte Dim flashdelay As Byte flashdelay=3 Do For ct=0 To 15 'Draw Z flash 0 flash 5 flash 10 flash 11 flash 7 flash 3 flash 4 flash 9 flash 14 Next For ct=0 To 15 'Draw E flash 0 flash 5 flash 10 flash 1 flash 2 flash 7 flash 12 flash 3 flash 4 flash 9 flash 14 Next For ct=0 To 15

'Draw D flash 0 flash 5 flash 1 flash 11 flash 2 flash 12 flash 3 flash 13 flash 4 flash 9 Next For ct=0 To 15 'Draw O flash 5 flash 1 flash 11 flash 2 flash 12 flash 3 flash 13 flash 9 Next For ct=0 To 15 'Draw M flash 0 flash 10 flash 1 flash 6 flash 11 flash 2 flash 12 flash 3 flash 13 flash 4 flash 14 Next For ct=0 To 15 'Draw A flash 5 flash 1 flash 11 flash 2 flash 12

flash 3 flash 8 flash 13 flash 4 flash 14 Next For ct=0 To 15 'Draw X flash 0 flash 10 flash 6 flash 7 flash 3 flash 13 flash 4 flash 14 Next

Loop End Sub flash(num As Byte) If num<5 Then Out a(num),1 Delay flashdelay Out a(num),0 Delay flashdelay Elseif num<10 Then Out b(num-5),1 Delay flashdelay Out b(num-5),0 Delay flashdelay Elseif num<15 Then Out c(num-10),1 Delay flashdelay Out c(num-10),0 Delay flashdelay End If End Sub

For the program, I simply made a function called flash, that will flash the designated part of the LED for like 5 miliseconds...

66

Taking it Further...

Yes, this was fun diy and I am actually gonna have a chance to use it for the halloween parade in SF!

Happy Holloween! <:)

Zedomax DIY115 How to Establish serial connection with PC's bluetooth 2.0 with a ACODE-300!
16

See Video on YouTube

Parts List
1 ACODE-300 1 ACODE-300 Interface Module 1 PC or Laptop (with Bluetooth) 1 Persistence

Okay, today at work I have been getting a lot of calls on how to connect the ACODE-300 serial to bluetooth converter module to a PC or Laptop with bluetooth... Well since the ACODE-300 is bluetooth 1.1 compliant and bluetooth 2.0 is backward compatible, the ACODE300 should have no problem in establishing serial connection with a PC. Why do you need this? Well let's say you are using an MCU (Microcontroller) such as AVR, PIC, Make Controller, Basic Stamp, or CUBLOC. If you were to use the ACODE-300 module on the MCU side and if you wanted to write a customized C++ or Visual Basic program on your PC to control the embedded module, you would need to know this. But since the ACODE-300 communicates via serial to the MCU, we have less stuff to develop and spend more time making things instead of stuck in fron of your hard-to-use bluetooth module or waiting for tech support over the phone. To test the serial communication, we can simple open up two HyperTerminals. I will use a PC connected instead of an MCU to the ACODE300 via a ACODE300 Interface Board and use my new HP Laptop that comes with Bluetooth 2.0 (and Lightscriber too, which can write labels to CDs...hehe) For example, the Bluetooth Hovercraft we made the other day, we could control the hovercraft via your PC or laptop instead of building another ACODE transmitter module (I don't know why I didn't realize this before...duh...)

67

HOWTO

Time to do: About 5 minutes... Anyways, getting back to MCU business here... To simulate, we are using my PC connected to the ACODE300 and my laptop, which needs no connection to anything since it is wireless via bluetooth 2.0. Okay, so insert the ACODE onto the ACODE Interface Board and connect a serial cable to the PC.

Next, you need a second PC or laptop with bluetooth. (You can buy a stamp sized bluetooth USB Dongle at Radio Shack or any other electronic gizmo shop)

PromiWIN4.0_Setup(En).exe Download Next open up PromiWIN on your PC with ACODE connected to the serial port, configure the ACODE-300 to 115200 bps, and also under "Security Option", check "Authentication" and "Encryption" and type in a password. (I used "1111" as my password) All PC Bluetooth and other bluetooth devices will ask for a security password for connections so you need to do this. Also set the ACODE to "MODE3". Hit "Apply" and you are ready to rock and roll.

Next, goto your PC or Laptop with bluetooth and find the bluetooth explorer. There, you should be able to find your ACODE bluetooth module like shown here:

Click right button, and "Pair Device".

Next, you will enter the password you set for the ACODE-300, so here I put "1111", which is my password. Notice that the device name "controller" is also same as what I set earlier with my ACODE-300.

Next, you will see a checkmark by the bluetooth module, meaning it's configured. Now double-click on the bluetooth module, and you will find that "Generic Serial on xxx" is under it like shown here:

Do you notice that the Bluetooth has been set to COM5 for serial communications? Simply open up your HyperTerminal and connect to COM5 or whatever port your bluetooth module is configured to.

Next set the baud rate to 115200 like the ACODE, and click OK!

Now open up Hyperterminal on your PC with ACODE-300 exactly same except you choose the right serial port number. Now if you type anything on the PC with ACODE-300, you will see it show up on your PC or laptop with Bluetooth. If you don't you probably have some setting such as baudrate not right...

68

Taking it Further...

Yes, you can take this further to make serial connection from your PC or Laptop's bluetooth to any type of MCU that supports serial communication. Next time, we will try testing this method with my pda phone HTC 8125...and maybe we can make a pda controlled hovercraft! Next time, let's make a small prototype bluetooth device we can control via our Laptop bluetooth...

<:)

Zedomax DIY116 How to Make make a Talking Halloween Basket!


17

See Video on YouTube My girlfriend asked me she wanted a cool halloween basket for her house on halloween, so I made her a halloween backet with some parts that I had lying around. I figured I could use the voice module that I bought at Radio Shack for like 10 bucks a couple months ago, so here it goes. We are going to use the PWM (Pulse-Width-Modulator) to make some glowing LEDs, and basic digital outputs to do a simple lip sinking action along with the voice module from Radio Shack.

This recording module is easy to use since it runs on 9V and comes with just 2 buttons, one for recording and one for playing.

Parts List
1 Halloween Pumpkin Basket ($1 from Target) 1 CUBLOC CB220 1 CB220 Proto Board 12 LEDs 6 330 Ohm resistors 1 9V Battery 1 20-Second Recording Module ($10 from RadioShack) Bunch of wires

69

HOWTO

Time to do: About an Hour and a half... First, let's make the circuit for our LEDs,make sure to use wires that are wirey (wire made up of wires), so your connections won't break when you put candy in it.

Now, solder on the 6 330 Ohm resistors like shown below, one end to GND, and the other open.

Then, sold on one of your wires, making sure they are long enough (about 6" should suffice)...

On the back solder the wire to the resistor together like this:

Next put the rest of the wires the same way:

The back of the CB220 Proto-Board would now look like this:

Bext, wire 6 wires to P5 through P10 of the CB220 Proto-Board like this:

When done, you should now have something like this:

Next we have to make some LEDs. Since each I/O can support about 2 LEDs, solder up 2 LEDs at a time like this:

Make sure solder long (Positive) end of one LED to short (Negative) end of the other LED. You should have One long end and one short end after soldering them together as shown here. The long end is the Positive and the short end is Negative.

You should now have 6 of these: (I only have 5 on the picture, but you should make 6!)

Next you will wire the short (negative) end of the LEDs to each wire from the resistors.

Like this:

When you wire them all up, you will have a big mess like this:

Next, for each of the long (positive) ends of the LEDs, solder them to the I/O port wires (P5 through P10):

After all the soldering, you should have another great big mess like this:

Next get your voice recording module from RadioShack and record a scary Halloween theme, there's a recording switch and a play switch.

Next solder one wire to P14:

Now solder the other end of wire to here: (This is the RadioShack recording module hack, it connects to the Play switch)

Next, solder 2 wires to the + and - of the recording module to get the 9V power out to the CB220 Proto-Board.

Solder the other ends to the CB220 Proto-Board Adaptor Jack like this: (The bottom part is the negative and the one on the upper-left is the positive of the CB220 Proto-Board)

Now download the Halloween_pwm program to your CB220 using a serial port like shown here and check that LEDs are flashing: Download Halloween_pwm Program

Okay, now get your halloween pumpkin basket.

Okay, you are ready to go, simply drill holes on locations you wish to use the LEDs. I chose the eyes, nose, and the mouth. You should make hole just big enough so you can stick the LED through and the LED gets stuck.

Drilled holes:

LEDs inserted:

The inside look: (You can do some more isolating with some electrical tape if you'd like, I was in more of a hurry, I had to make it in an hour...)

Tape up the Proto-Board: (It's a mess but you could probably do a better job than I did...)

Now stuff some candies and you have a talking pumpkin basket!

Enjoy the eyes glowing and you can change some of the delay parameters in the program to match your voice to get some sorta lip-sinking!

70

Taking it Further...

Yes, you could use this for any type of halloween device whether that be a skull head, your personal costume, or whatever... Since you are using wires to the LEDs, it's easy to drill into holes into any other object and make a talking halloween device with flashing LEDs...

Zedomax DIY117 How to Make a Digital Drawing Board with an old joystick in 5 minutes!
18

Watch Video on YouTube

Parts List
1 CUBLOC CB280 1 GHLCD Graphic LCD 1 Old Analog Joystick Couple wires

71

HOWTO

Time to do: About 5 minutes plus time it takes to take a joystick apart. (I was able to skip this part as Garret gave me a joystick that was taken apart already. Today, Garret, my new co-worker, gave me couple of old analog joysticks he had lying around that was from old rc controllers.

Well an idea hit me and I pondered what I can make that would be easy and fast but would be useful. I decided I could simply read the analog values using a CUBLOC module and make a digital drawing board.

So I had 3 joysticks to choose from. I figured on the one that is on the most right from the above picture.

I've never worked with joysticks before, but I noticed that all the joysticks had 3 outputs like shown above. Garret explained to me that the left pin is for ground, the right pin is for VCC (5V), and the middle pin is an analog output for the axis. I noticed that there are two axises, X and Y on these joysticks.

WIthout any delay, I soldered two wires for the Ground and VCC so I only have to power one axis to power both axises. The Blue wire above is Ground and Red wire is the VCC.

Next, I wired a yellow wire for the Ground and VCC plus a wire for each analog output of each axis.

Next, I simply plugged in Ground wire to Ground of the Study Board, VCC wire to 5V of the Study Board, X Axis wire to P25 (analog channel 1) of the Study Board, and Y Axis wire to P24 (analog channel 0) of the Study Board.

View from the top side is shown here:

Next I made a simple program that would receive inputs: Const Device = CB280

Dim a As Integer Dim b As Integer

Input 24 Input 25

Do a=Adin(0) b=Adin(1) Debug "Up & Down Value: ", Dec a,Cr Debug "Left & Right Value: ", Dec b,Cr Delay 100

Loop

This program prints the value of the X and Y analog outputs of the joystick. Since I didn't know what analog voltage I was supposed to receive, I simply ran the program and noted the analog input values when the Joystick was in the center, left, right, down, and up.

Now with those values, I could calibrate my program to know when to move the cursor to the left, right, up, and down. Here is part of the BASIC code for the XAxis:

#define XCENTER 270 #define XLEFT 375 #define XRIGHT 148

If X > XCENTER -10 And X < XCENTER +10 Then 'do nothing Elseif X > XCENTER+10 Then 'move left MLeft Elseif X < XCENTER-10 Then MRight End If

MLeft and MRight are sub functions that will simply re-draw the cursor about 8 pixels to the left and right. I would give about value of 10 (AD input returns a value between 0 to 1024 for voltage between 0 and 5V), as a safety value for debouncing and shakes. Likewise, I made similar functions for up, down, and diagonal directions. Download JoyStick Program here Well you can download the JoyStick Program using CublocStudio and see this initial screen:

Completed Look of the Digital Drawing Board:

You can use the pushbutton on the Study Board to draw!

72

Taking it Further...

Yes, you could use these old joysticks for anything like a remote-controlled robot, drawing board, or anything that requires left, right, up, and down buttons. Next time, we will see if we can make a bluetooth joystick... <:)

Zedomax DIY118 How to Make a Golf Club POV training aid! - Golf Club POV version Ben Hogan
19

Watch Video on YouTube (We want to thank Carlos from CertaPro Painters in Foster City for letting us borrow his warehouse for the shooting!)

The other day, Garrett hit up on some basic POVs. So we were thinking about how we could have a POV while making it useful. Well since people like to hit up the driving range or the golf course at times, we figured we could just make a POV out of a golf club. At the same time, we can make it kinda useful too. As you can see, the letters will go backwards on the backswing and forwards on the forwardswing. Ben Hogan's "Five Lessons" has a good picture of correct swing arc for a golf swing. Actually that is the reason we named it after the great American golfer, Ben Hogan. I am sure Ben Hogan would be proud of our little POV that can allow you to capture your swing arc using a digital camera. You take a look at Taking It Further page for more information on how this device can help your golf swing analysis.

Anyways, here's some pictures of the Golf Club POV.

The World's very first Golf Club Persistance Of Vision! (Programmable Golf Club)

(Ready for some action!)

Parts List
1 CUBLOC CB220 1 CUBLOC CB220 Proto-Board (available from cubloc.com) 8 High Output Blue LEDs (Part #: 183222) 1 empty semiconductor sleeve (or some type of plastic enclosure) 8 100 Ohm resistors (Anything between 50 to 100 Ohm will work) 1 9V Battery (available from Jameco) 1 Golf Club (preferably something between 7 iron and 3 iron) Couple wires $34 $5

$3 each Find something like it! $1 each $2

73

HOWTO

Parts List (Again): 1 CUBLOC CB220 $34 1 CUBLOC CB220 Proto-Board $5 (available from cubloc.com) $3 each 8 High Output Blue LEDs (Part #: 183222) 1 empty semiconductor sleeve (or some type of see-through plastic enclosure) Find something like it! 8 100 Ohm resistors (Anything between 50 to 100 Ohm will work) $1 each 1 9V Battery $2 (available from Jameco) 1 Golf Club (preferably something between 7 iron and 3 iron) Couple wires

Time to do: About 2 hours.

First thing we gotta do is make some holes for the ultra-bright LEDs from Jameco on the semiconductor sleeve. The ultra-bright LEDs from Jameco had an outer layer at the bottom which had a bigger diameter. So we figured we can make a small hole for the top of the sleeve so the LED will snuggly fit onto the semiconductor sleeve. So use a precision measuring tool like Garrett did here:

We found that the LED diameter was about 5mm, so we found a drill that was about 5mm as shown here:

Measure out holes 1 inch apart and mark it like shown here:

Using the 5mm drill, we drilled 8 holes on the sleeve, straight-through it.

Next we managed to find the diameter of the outer layer which was about 6mm.

We found a drill about 6mm as shown here:

Next use the drill for the BOTTOM holes of the sleeve. So the whole LED will go through the sleeve but not the TOP holes.

Next stick each of the LEDs into the sleeve like shown here:

and here:

You can use a screwdriver to push in the LEDs like shown here:

When you finish inserting all 8 LEDs, you should have something like this:

Next we figured we wanted to test the circuit before actually putting it together, but you can probably skip this step if you want.

Simply test your LEDs, and see if you can make this program work and make all the light come on. You will probably have to play with some resistors and wires...

Once done testing and making sure your circuit works, tie up your sleeve to the bottom of the golf club using some electrical tape:

Next using wires connect to the longer (POSITIVE) sides of the LEDs. Make the wires about 2 feet in length so it can reach the embedded computer CUBLOC later on.

Solder it or tape it:

You should get something like this:

Use a tape to cover it:

For the other side (the shorter side of LEDs), connect a 100 Ohm resistor to each LED and pair them like this:

Then you should use one wire to hook up to the bottom of each resistor pair, this wire will eventually goto the ground of our CUBLOC proto-board.

Now grab your proto-board and cut in half like this: (I am using one of my older boards here, so you can ignore the parts on it.)

We need a little case for the proto-board. So I simply took the CB220 plastic case that comes with the CB220 and made some holes to fit it.

I used a solder to melt some holes, but I don't recommend it as it's bad for the environment and I got a big headache for like an hour...

You need holes for the I/O pins, this is where all your LED positive wires will hook up to.

Completed case with programmable serial port and DC jack hole:

Next take each of the positive LED wires you hooked up earlier and bring it through the big I/O hole:

Bring all of the I/O wires through the hole and solder it to the CB220 I/O ports from P8 to P15 like this:

Bottom view of the proto-board:

No put the proto-board back in the plastic case and you should get something nice like this:

Tape up everything together and add a 9V battery too.

Now go out there and make some practice swings.

(Above is Garrett swing the golf POV)

Looks like Garrett need help with his follow-though...

Yes, I need some help too with my impact...

OOOOOO..... Os by Garrett

Nice swing by Jackie!

See next page for Taking It Further...

74

Taking it Further...Applying to Swing Analysis

You could probably take pictures and check out your swing arc for swing analysis.

As you can see, the letters will go backwards on the backswing and forwards on the forwardswing. Ben Hogan's "Five Lessons" has a good picture of correct swing arc for a golf swing. You will see somewhere in the book of something similar as the below picture but without LEDs...

(Not too shabby huh? The letters say "HELP" here, yes help Max fix his swing...) Check out this comparison with Ernie Els:

It would usually require a V1 Golf Video analysis for you to analyze your swing arc, now you can do it for around $60 and a digital camera. <:) Max's Backswing to Finish:

Garret's Follow-through:

Jackie's follow-through arc:

Golf POV Program Download Again

Zedomax DIY119 - Make Christmas Light controller in 5 minutes!


20

View DEMO Video on You Tube

Okay, today we are going try to build a computer controlled Christmas Lights in 5 minutes. Ive been rolling around the neighborhood this late November and some people already have their Christmas lights decorated. Well Ive seen many static Christmas lights that always stay on. Today, I will show you how you can customize your Christmas lights by using a PLC, a Programmable Logic Controller. Update: Garretts Voice Activated Christmas Controller is now available!

75

Parts List

1 CuSB22R from cubloc.com 1 AC power cord (like the one for your computer or get it here: cubloc.com) 3 AC Connectors from Home Depot (You can get more depending on how many Christmas Lights you are trying to control,

remember you can also put Christmas lights in series per relay)

bunch of wires

First you will need to cut off the AC power cord and you will find 3 wires, one green, one black, and one white. Simply splice them and hook up the green wire to the CuSB where its labeled FG, which is frame ground so your house does burn down. Screw in tightly.

Then put the other Black and White wires onto the terminal headers as shown below. Black and White wires do not have polarity, so you can put either or onto the CUSB labels, N and L. Leave them unscrewed and only screw in the green wire if you havent done so in Step One.

Connect a wire from CuSB label COM to CuSB label, N Connect from CUSB label, P40, to one of screws on the AC connectors. Polarity doesnt matter so any of the two screws will work.

Screw in tightly.

Do the rest of the AC connectors. Connect from CUSB label, P41, to one of screws on the AC connectors. and also connect from CUSB label, P42, to one of screws on the AC connectors.

Connect from CUSB label, L, the white wire in the picture to the other screw on the AC connectors for each of them.

When you are done, you should have something like below.

Connect some Christmas lights to each of the AC connectors. Then connect the serial cable to program the unit.

Copy and paste the following code into CublocStudio and download to your CUSB.

76

Source Code

Const Device = CB280 Dim Interval As Long Interval=300 Do High 40 Low 41 High 42 Wait Interval Low 40 High 41 Low 42 Wait Interval If Interval>100 Then Interval=Interval-50 Elseif Interval>0 Then Interval=Interval-10 Else Interval=300

End If Loop

Taking It Further
Well your lights should be working pretty good now. You can change the Interval=300 line so the lights start blinking slower or make a completely different program for your Christmas. If you put it on a deer structure or something, you can probably time it so it is animated.

Zedomax DIY120 How to Make Voice Activated Christmas Lights!


21

View DEMO Video on You Tube

In this article well show you how to build a Christmas light controller! The basic concept can easily be expanded to many individually-controlled circuits. Any predefined animation pattern can be displayed, and the system can also respond to voice or music. First of all, check out the video to see how everything works.

77

Circuit Explanation

Next, lets take a look at the schematic. Ive constructed this circuit using a CB280 controller on a CB280-Proto board, along with an SSR4 board and several pieces of electrical hardware. The analog portion of the circuit is based on half of an LM324N quad op-amp I had on hand. The first stage acts as an amplifier for the small signal received by the electret microphone. The second stage acts as an integrator, since were interested in the overall sound level rather than the actual waveform. The larger the value of C1, the slower the circuit responds to volume changes. This circuit was quickly designed on a breadboard and values tweaked until desired operation was achieved. No doubt a better circuit could be developed with a larger time investment, but this does the job. Additional devices on the breadboard include a potentiometer wired as a voltage divider; this is used with an analog input on the CB280 controller as a simple speed control. There is also a pushbutton with pullup resistor, used for switching display modes. The circuit also uses the CB280-Proto boards integrated piezo speaker on Port 48 to indicate the current display mode after the button has been pressed.

78

Building the Controller

Nothing left but to grab the hardware and a soldering iron! Here Ive already soldered the LM324 op-amp into the CB280-Proto board.

The microphone and potentiometer are there, only need the pushbutton and were done soldering!

The SSR4 board is ready to go. Ive cut some jumper wires to carry the ground signal between the terminals.

SSR4 board is has all the signal wires attached; Ive snapped everything onto a DIN rail (handy to use if your hardware comes prepared for it).

Now Ive run the wires over to the terminal blocks I selected for my output ports P0, P1, P2, and P3.

Using zipties, Ive fasted the AC jacks onto the DIN rail, and started wiring them up to the SSR4 outputs.

And heres the completed project! Ready to add custom animations or sound response to a Christmas tree or the

front porch.

79

Code Explanation

In the following section, I will go through the controller code and explain the purpose of each part. Listing 1.
' Sound-reactive Christmas Light Controller ' Also contains several sequences without sound input Const Device = CB280 Ramclear ' Enable input on ADC Channel 0 Input 24 Input 25 Dim Dim Dim Dim AnalogIn As Integer ' ADC Value Mode As Byte ' Sequence Mode LightMap As Byte ' Contains the levels to be sent to the relays Speed As Integer ' Contains the speed setting

Mode = 0 ' Start in voice-reactive mode LightMap = 0 ' Clear output register ' Set interrupt to first external interrupt channel on Port 20 ' Will generate interrupt on falling edge On INT0 Gosub ChangeMode Set Int0 0

In Listing 1 Ive initialized the controller and any variables I will need. The code is pretty self-explanatory; the device type is set, the analog inputs are initialized, and the interrupt for the mode change button is started. Listing 2.
' Main Program Loop Do ' Read potentiometer for speed adjustment Speed = 1024 - (Tadin(1)) ' Choose the display mode Select Case Mode

Case 0 Gosub SoundReact ' Use outputs as indicator of sound level Case 1 Gosub Expander ' Sequence outputs one at a time from 0 to 3 Case 2 Gosub Contracter ' Sequence outputs one at a time from 3 to 0 Case 3 Gosub Bouncer ' Sequence outputs back and forth between 0 and 3 Case 4 Gosub Filler ' Display a bar graph that rises and falls End Select ' Write only the lower 4 bits of LightMap to the output Out 0,LightMap.BIT0 Out 1,LightMap.BIT1 Out 2,LightMap.BIT2 Out 3,LightMap.BIT3 Loop

The main program loop is contained in Listing 2. Every time the program loops, it checks the analog input that is wired to a potentiometer. The controller converts a 0V to 5V level to a number between 0 and 1023. This is used to provide a delay value to various subroutines, with the net result of adjusting the animation speed. Next, there is a SelectCase statement which chooses one of the animation subroutines to execute, based on the current status of Mode. A subroutine will put the next desired pattern into the LightMap variable. Then the main loop writes the lower four bits of LightMap to the P0, P1, P2, and P3 ports, which are wired to the SSR4 board and then to the Christmas light strings. Listing 3.
' Responds to interrupt on Pin 20, increments current mode ChangeMode: If (In(20) = 0) Then Dim k As Byte Incr Mode If (Mode > 4) Then Mode = 0 ' Beeps the number of times that correspond to current mode For k = 0 To Mode Beep 48, 30 Delay 250 Next Delay 500 Endif Return

In Listing 3 the external interrupt connected to the pushbutton is used to increment the Mode variable. It then beeps the piezo speaker one through five times, depending on the value of Mode. Then it waits for a short time to minimize double presses and contact bounce. Listing 4

Expander: ' Sequences light one by one from port 0 to port 3, then repeats LightMap = LightMap < < 1 ' Shift left If (LightMap.NIB0 = 0) Then LightMap = &b00000001 ' Start over Delay Speed + 30 ' Don't want to strobe to fast, might damage Christmas lights Return

The Expander routine is shown in Listing 4. It simply shifts a 1 through the LightMap value and returns to the main loop. When it detects that 1 has been shifted out of the lower nibble of LightMap, it resets the pattern. Ive also added a delay of 30 to whatever speed is currently set, to put an upper limit on how fast the lights can cycle. Listing 5.
Contracter: ' Sequences light one by one from port 3 to port 0, then repeats LightMap = LightMap >> 1 ' Shift right If (LightMap.NIB0 = 0) Then LightMap = &b00001000 ' Start over Delay Speed + 30 ' Don't want to strobe to fast, might damage Christmas lights Return

Contracter in Listing 5 is basically the same as Expander except it move the active output in the opposite direction. Listing 6.
Bouncer: ' Sequences light one by one from port 0 to port 3, then in reverse ' Look at top nibble of Light Map. ' If a bit is in there, keep shifting left ' If we've shifted it all the way out the top, start shifting right If (LightMap.NIB1 > 0) Then LightMap = LightMap < < 1 ' Shift Left Else LightMap = LightMap >> 1 ' Shift Right Endif ' If we've shifted left (getting rid of byte in top nibble) and we've ' shifted right all the back to starting position, put bit back in NIB0 ' Also if LightMap = 0 we want to initialize it If (LightMap < = 1) Then LightMap = &b00100001 ' Start over Delay Speed + 30 ' Don't want to strobe to fast, might damage Christmas lights Return

The Bouncer routine in Listing 6 is basically an Expander followed by a Contracter. The starting pattern has a bit set in the upper half of LightMap that is used as an indicator of which direction to travel. Once it is shifted out the top of the bit, it will disappear and then the routine begins shifting the other direction. Listing 7.
Filler:

' Slight changes to Bouncer pattern, so that pattern fills up and empties ' Like a bar graph rising and falling ' Look at top nibble of Light Map. ' If a bit is in there, keep shifting left ' If we've shifted it all the way out the top, start shifting right If (LightMap.NIB1 > 0) Then LightMap = LightMap < < 1 ' Shift Left LightMap.BIT0 = 1 Else LightMap = LightMap >> 1 ' Shift Right Endif ' If we've shifted left (getting rid of byte in top nibble) and we've ' shifted right all the back to starting position, put bit back in NIB0 ' Also if LightMap = 0 we want to initialize it If (LightMap = 0) Then LightMap = &b00010000 ' Start over Delay Speed + 30 ' Don't want to strobe to fast, might damage Christmas lights Return

Filler in Listing 7 is a modfied version of Bouncer that keep writing a 1 to the lower bit. This causes LightMap to fill up like a bar graph, and then go back down once it has filled up all the way. Listing 8.
SoundReact: ' Receive analog input from a microphone and generate an output ' map that corresponds to sound level. Essentially a bar graph. Dim i As Byte ' Take many samples to reduce reaction time to ' a level that won't burn out our relays For i = 1 To 25 AnalogIn = AnalogIn + Adin(0) Delay 3 Next ' Divide by number of samples to get the average value AnalogIn = AnalogIn / 25 LightMap = 0 If (AnalogIn If (AnalogIn If (AnalogIn If (AnalogIn Delay 50 Return

> 5 And AnalogIn < 50) Then LightMap = &b00000001 >= 50 And AnalogIn < 150) Then LightMap = &b00000011 >= 150 And AnalogIn < 300) Then LightMap = &b00000111 >= 300) Then LightMap = &b00001111

SoundReact in Listing 8 listens to the microphone and determines the current sound level. It does some additional analog sample averaging to slow down the response to viewable speeds, and then it assigns LightMap according to the averaged value.

Additional photos of the project in operation:

Zedomax DIY121 How to make your own PS3 SIXAXIS controller style BASIC-programmable USB device!
22

View Demo Video on YouTube USB devices are easy for users to install and set up (as long as everything is working correctly). Often, you just plug in a USB device and it works immediately. This is especially true for input devices, such as mice and keyboards. Those devices conform to a specification layered on top of the USB protocol: Human Interface Device. Almost any possible type of input is defined; an entire report descriptor language is used to tell the computer how to process the input. This is not very simple to implement; dozens of specific requests must be handled properly. There are many steps between plugging in a USB device and being able to use it; these all take place in a few milliseconds and failure of any step means the device will not work. What if you didnt have to worry about any of that? What if you could use your favorite microcontroller, do something and the input appears on the computer in the correct format? You wouldnt have to worry about complex USB code, HID specifications, or breaking your USB code when adding the other functions you need. You wouldnt have to worry much about writing optimized code, or always getting in the way of USB interrupts.

80

HID Portal

Thats exactly what I decided to do. A couple of years ago, I developed a USB device and went through all the headaches of getting a USB HID up and running. Since I already had the hard work done, I decided to add a method of receiving data from another microcontroller and using that data as the input stream for the HID code. I wanted to use a Cubloc BASIC-programmable controller to process my input data and send it to the HID Portal. My test application would be an accelerometer-based HID joystick; simply plug the device into the computer and it will work.

It doesnt have to be a joystick; it could be a keyboard, a mouse, or many other controls defined by the HID standard. Its possible to add volume control buttons to a devicemaybe have a circuit mute your computer when the phone rings? Turn any voltage input into a joystick axis, any switch into a button? Anything is possible! Update:I decided to shrink the CUBLOC hardware down to a CB220, and fit everything into an airplane model. The model was chosen to match an airplane available in the Heroes of the Pacific game we used to test the joystick interface.

81

Hardware Explanation

The HID Portal is based on an old project of mine, based on an MC68HC908JB8 microcontroller and programmed in assembly language. For certain reasons I cant actually release the code right now, but there are plenty of other USB projects out there which could be adapted for this purpose. Theres an open-sourced soft USB implementation for the ATtiny microcontroller, for example. My microcontroller doesnt have built-in I2C or SPI, so I needed to implement one of my own. I also didnt have interrupt pins available, meaning my solution needed to be based on polling. When all was said and done and optimized, I couldnt detect edges faster than 16Khz. This is about ten times slower than the shift output available from the CUBLOC controller, so I couldnt use that. I ended up writing my own shift-out routine in BASIC to get the data to the HID Portal. This could be avoided by using a microcontroller that has SPI or I2C built in already, but the JB8 is what I had on hand.

I use three signals to communicate with the CUBLOC controller. First, there is a CLK signal. The HID Portal detects a rising edge. At that point, it reads the value present on the DATA line. This is shifted into a register until a byte has been received, and the code moves to the next byte. The /RST line is a way to synchronize the start of each data packet in case there was any spurious input; when LOW it sets the packet and bit indexes to zero. The HID Portal is currently programmed to act as a joystick with three axes and eight buttons. Ive also tested it as a keyboard. In future development, Id like to make the HID Portal more flexible; let the external controller select the device type and how many of each input are required. It would be the most flexible if it directly accepted HID report descriptors, but that opens up the possibility to make more mistakes and end up with a nonworking device. The accelerometer is a DE-ACCM3D from Dimension Engineering. The CUBLOC simply reads the voltage on its ADIN ports and converts to a value between -127 and 127.

82

Building the HID Portal

I had parts left over from the old project, as well as some boards that I had manufactured. After a lot of digging through old boxes, I started with this:

After a bit of soldering, I ended up with this:

There is a USB device and then a programming dongle to write the flash on the microcontroller.

Then came a couple days of getting back into the old code, breaking it repeatedly, and finally ending up with a working HID portal device. I wired everything together using a CUBLOC 405 proto board. I could have used a much smaller CUBLOC, like the CB220, and it would have worked the same way.

Update: Heres some details regarding construction of the USB Corsair. I wanted to preserve the look of the airplane as much as possible, but still make it functional as an input device. First of all, I needed a way to get communication and power into the airplane. I needed power, ground, CLK, Data, /RST, and three lines for the serial port because I want to program the CUBLOC without taking the airplane apart. The following photos show the wing section of the Corsair, and where I planned to install jack:

Next, I epoxied an Ethernet jack to the air scoop. It carries eight conductors, which is exactly what I need.

After the epoxy hardened, I wired the appropriate lines to a serial connector for use with the CB220 Proto board. Ive already soldered a socket on the board for the accelerometer module from Dimension Engineering.

Ive soldered a header onto the proto board and have started soldering all the connections Ill need.

I need to add buttons to the airplane, so I drilled holes on either side of the fuselage and inserted a button in each.

Here Ive glued in a potentiometer for throttle control, as well as mounts for the proto board, and two orange LEDs to simulate glow from the exhaust. I have no idea if there actually would be glow, but it looks cool.

This is the wiring harness for the other end of the Ethernet cable. Ive split off connections for serial and power, as well as a wire that connects to my USB device.

This is what the completed wing and body sections look like, with buttons and LEDs installed. Ive also placed a small DC motor in the nose to make the propeller spin.

The controller board is done, so Im gently securing it inside the wing section with a few zip ties.

Snap all the headers in place, put the wing section on the body section, and everything should be ready!

Heres how the connection to the airplane looks.

83

Code Explanation

Usually I split my code into segments and explain each one; this time I decided to add most of the documentation as comments within the code. Its really not complex; most of the real work is done inside the USB microcontroller. As explained above, I needed to develop a slower way to shift bits to the HID Portal. Also, the joystick data needed to be formatted as twos complement signed bytes. To convert a number to its twos complement negative equivalent, you simply invert all the bits and add one. Update:The actual code for the airplane is a little different from this demo code. It uses a CB220 instead of the CB405, and it changes the output pins slightly, plus a little PWM control of the spinner motor and the LEDs.
' Created On 12/06/2006 ' Garrett Mace ' Comfile Technology, Inc. ' USB HID Portal Demo ' Demonstration code for a device that can be used by a CUBLOC ' to send commands to a PC as an HID (Human Interface Device). ' Current implementation of the device is a USB joystick with ' Throttle, X axis, Y axis, and Button 1 through Button 8. ' ' ' ' ' ' ' ' ' ' Packet structure: | Byte 0 | Byte 1 | Byte 2 | Byte 3 | +----------+----------+----------+----------+ | Throttle | X axis | Y Axis | Buttons | +----------+----------+----------+----------+ | +/- 127 | +/- 127 | +/- 127 | 8 bits | Device signals: CLK: Shift register input clock DATA: Shift register input data /RST: Reset packet and shift register

' This example code is distributed as-is and ' is not intended for critical applications ' involving the risk of damage or injury. ' Device initialization Const Device = CB405

' Set outputs to initial values Low 24 ' CLK Low 25 ' DATA Low 26 ' /RST ' Set up Dim i As Dim j As Dim A(4) Dim B As necessary variables Byte ' Bit shift counter Byte ' Packet byte counter As Byte ' Packet byte array Byte ' Register to be shifted to USB controller

' Use LONG variable for averaging and negative numbers Dim Throttle As Long Dim X As Long Dim Y As Long Delay 10 ' Allow /RST to set USB controller to default values

' Main program loop Do ' Read analog channels 25 times and sum the result For i = 1 To 25 Throttle = Throttle + Adin(0) X = X + Adin(1) Y = Y + Adin(2) Next ' Divide by 25 and any necessary factors X = -(X/25 - 341)*1.5 ' Subtract normal offset value at 0g, multiply for better sensitivity Y = -(Y/25 - 341)*1.5 ' Subtract normal offset value at 0g, multiply for better sensitivity Throttle = 128-Throttle/100 ' Divide by 25*4 to convert 0-1023 value to -127 to + 127 value ' USB HID requires two's complement representation for signed bytes ' Two's complement means inverting and adding one If (Throttle >= 0) Then A(0) = Throttle ' If value is positive, assign as-is to a Byte value Else A(0) = (Abs(Throttle) Xor 255) + 1 ' If value is negative, invert and add one Endif ' USB HID requires two's complement representation for signed bytes ' Two's complement means inverting and adding one If (X >= 0) Then A(2) = X ' If value is positive, assign as-is to a Byte value Else A(2) = (Abs(X) Xor 255) + 1 ' If value is negative, invert and add one Endif If (Y >= 0) Then A(1) = Y ' If value is positive, assign as-is to a Byte value Else A(1) = (Abs(Y) Xor 255) + 1 ' If value is negative, invert and add one Endif ' Assign entire port 6 to the button byte ' Buttons are mapped as 0 or 1 A(3) = Bytein(6)

' Send data packet to the USB controller ' My controller's shift-in implementation is too slow to cope with ' the built-in CUBLOC shiftout speeds High 26 ' Take shift and byte register out of reset For j = 0 To 3 B = A(j) ' Assign current byte to the shift out register For i = 0 To 7 Out 25,B.BIT7 ' Write the current high bit to the DATA line B = B < < 1 ' Shift the register one bit up High 24 ' Assert the CLK line Low 24 ' Deactivate the CLK line...one pulse complete Next Next Low 26 ' Put the shift and byte register back into reset Loop

Zedomax DIY122 How to Make a LED Christmas Tree!


23

In this special Christmas edition of Zedomax DIY122, we will show you how to make the geekiest Christmas Tree in the world using LEDs, bathroom pipes, and an embedded cubloc module. Check out Pictures of the finished Christmas Tree See DEMO Video on YouTube

84

Parts list

1 CUBLOC CB220 Module 1 CUBLOC Proto-Board 1 PC Fan 8 High Output Green LEDs from Alan's store 8 High Output Red LEDs from Alan's store 1 Tub and Shower Knob 1 Tub and Shower Piping that fits the Knob (I used Watts 713322BA from Home Depot) 1 9V Battery 1 Plastic folder 1 Glue Gun 1 3M Tape

1 13

Tub and shower piping

Get your tub and shower pipe and stick it into the shower knob and screw in tight.

1 16

If should look like this:

1 14

PC Fan wrecking

Next, get your PC fan and cut out the 3 supporting legs as shown here:

1 17

You should get this

1 18

Now, pop it out

85

Putting tub and shower piping and the FAN together

Hot glue the fan to the screwable part on the tub and shower piping:

Now you can fit the fan power through the pipe so the wires end up at the bottom.

Finished Product should look like this:

86

Making the branches for the tree

Now grab your tub and shower knob, (yes take it out again...sorry) and place it about 1/3 of a page from the left like shown here and make a circle.

Now get something to draw a bigger circle than the circle you drew. I got my thread thingee that would do the job here. You should end up with a slightly bigger circle. This is so there is space in between the pipe and the plastic branch we are making.

Now we need a larger circle outside all the circles. This will be the actual outside layer width. Also draw lines outside the circle like shown here.

Now place another layer of the plastic binder on top of the circles you just drew.

We need a stopper which will not allow our bottom branch to climb when the speed of the PC fan is increasing. So make something like this:

87

Start cutting the plastic branches you made!

You will need two of these so make two:

Now fold the flap on the stopper we made and fit it through the pipe. Also get the plastic branch to fit under it too.

Now cut out some pieces of the plastic binder that you will be using as side branches:

Make sure the pieces are long enough by measuring from the bottom branch to the top of the PC fan for each side.

Tape them together if it's too short:

Notice how I am doing it roughly here, but you could probably do a better job.

Tape the stopper:

Now tape it up like this just to see if it works:

Next, get the other branch we made earlier and put it in the middle like this:

88

Electronics Put the LEDs on branches

89

Okay, now you've got the physics, let's get into the nitty gritty electronics now. So take your side branches out, one should be slightly longer than the other to have an outside and inside layer for the Christmas Tree. The outside layer will simply server as a the green tree itself and the inside layer will be red letters. So begin by measuring out evenly 8 dots for the longer side branch:

Then measure out evenly 8 dots for the short side branch: (make sure this is close to the bottom of the branch, even though I didn't do that. And make sure LEDs will be closely spaced to ensure good lettering of the POV.)

90

Longer side branch wiring

Get your longer side branch and make the holes for the LEDs:

Try to fit each LED the same way. I have the shorter pin of the LED on the left side which is ground. I will hook up all the ground together later.

You should have something like this with all LEDs in:

Flip it and scotch tape the longer pin side like this:

Hook up all the ground side using wires and solder and thin wires like this:

Now move the scotch tape to the side we just finished:

Next, wire up each of the longer pin side of the LEDs and bring the wires up to the top:

You should end up with 8 wires for the longer pin side of LEDs and 1 wire for ground like shown here:

91

Shorter side branch wiring

Make holes again:

When you have something like this:

Flip the shorter pin side (ground) of the LEDs together like this:

Solder them together:

Wire the each of the other side individually like before:

92

Put it together
Schematics

1 15

You will need to the proto-board to be something like this:

and end up with something like this:

With all wires connected, end up with something like this:

93

Source Code

Program using this code:


Const Device = CB220

Const Byte Charset = ( 'Merry! Christmas! 'M 0b11111111, 0b00000100, 0b11111111, 0b11111111, 0b10001001, 0b10001001, 0b11111111, 0b00011001, 0b11100110, 0b11111111, 0b00011001, 0b11100110, 0b00001111, 0b11110000, 0b00001111, 0b11111111, 0b10000001, 0b10000001, 0b11111111, 0b00011001, 0b11100110, 0b00000000, 0b11111111, 0b00000000, 0b10000110, 0b10001001, 0b01110001, 0b00000100, 0b11111111, 0b00000100, 0b11111111, 0b00000100, 0b11111111, 0b11111110, 0b00010001, 0b11111110,

0b10000110, 0b10001001, 0b01110001, 'animation 0b00000001, 0b00000011, 0b00000111, 0b00001111, 0b00011111, 0b00111111, 0b01111111, 0b11111111, 0b01111111, 0b00111111, 0b00011111, 0b00001111, 0b00000111, 0b00000011, 0b00000001

Dim i As Byte Dim j As Byte Dim k As Byte Dim Character As Byte Do For k=0 To 5 For j=0 To 12

For i = 0 To 2 Byteout 1, Charset(j*3+i) Udelay 600 Byteout 1, 0 Next Udelay 900 Next

Next Delay 1000 For k=0 To 20 j=13 For i = 0 To 14 Byteout 1, Charset(j*3+i) Delay 25 Byteout 1, 0 Next Next Delay 1000 Loop

Now cut out a piece of plastic the width of the proto-board, this will go under the proto-board eventually.

Next, tape up to the two side branches and hot glue them together:

Hot glue the whole board and the side branches to the top of the PC fan:

Hook up a 9V battery:

94

Tips

Garrett made me some easy connectors here so I can plug the side branches in and out of the proto-board if I wanted to. Notice I hot glued any parts that might fall apart later.

Start with a full size proto-board and cut it appropriately to cut down on the weight:

95

Taking it Further

Well, this can really be made into other cool looking POVs. It's really up to your imagination now.

Zedomax DIY123 - HOW TO make a Christmas LED wreath!


24

View This Video on YouTube We were thinking that we could make another last minute DIY for that uses a Ryobi FAN from Home Depot, high output LEDs, and an embedded computer. Although we have been spending way too much time making DIYs and not working, we are glad we did make a cool Christmas LED Wreath we are proud of. The video by the way did not capture the real effect because of the frame rate of the camera but the pictures can be seen Merry Leddy Christmas!

96

Parts List

1 CB220 1 CB220 Proto-Board

or you can get a Make POV kit and just put some high output LEDs on it.

4 High Output Green LEDs from Alans store 4 High Output Red LEDs from Alans store

We noticed Alans LED store had much cheaper price for same high output LEDs wed usually get at Jameco.

1 Plastic Case from Poker cards 1 Ryobi rechargeable fan from Home Depot 8 100 to 330 Ohm resistors (We used 100 Ohms for high output LEDs) 1 Terminal Pin thingee (for connecting PCB board together) 1 9V or 12V battery (we noticed 12V battery for cameras are smaller and lighter)

97

HOWTO

First, we try to fit the protoboard, the plastic case, and the 9V battery onto the fan.

Then we cut up the protoboard into some pieces and soldered it together like shown here:

Next, we soldered up all the LEDs, making sure the shorter side is inserted onto label GND, which is ground of course.

Next, solder up the rest of the parts of the CB220 Proto-board

Solder on the 8 resistors onto the I/O pins. The other end of the resistor will goto each of the LEDs. You can also solder on a 9V battery connector. (get it from Alans store too)

Download the program and power up the module: (The program source is at the end of the HOWTO) You should end up with a nice little package like this:

Next cut off pieces of the plastic case so the proto-board will fit and balance your proto-board, plastic case, and the battery together on your finger like this: Make sure to mark the spot with a marker

Next you can align the spot with the center of the fan and drill 3 holes to hold the plastic case. Make sure to high five your partner if you made it to this point! Max is high fiving Garrett here:

Next, power on the module combo and start enjoying some Merry Leddy Christmas! Get Source Code here

Zedomax DIY124 - HOW TO make a $50 golf training aid for 5 bucks!
25

View This Video on You Tube Its getting near Christmas time and I needed to prepare some Christmas gifts for my parents. Since my Dad does not get much time on the golf course these days, I figured I could make a training aid he could use at home to keep his swing on path. Since I didnt want to spend 50 bucks on the golf training aid, so I decided to make one real quick.

98

Parts List

1 Red High Output LED $ 0.20 1 Green High Output LED $ 0.25 1 Hose clamp from Orchards Hardware or Home Depot (around 1" diameter works good) $1.19 1 Plumber tape (has holes perfect for LEDs) from Orchards Hardware or Home Depot $1.99 1 9V Battery (You can use smaller batteries but 9V battery lasts longer) $3 1 9V Battery Connector $ 0.45 few wires

Total Cost: about $5 Total Time to Make: about 20 minutes

99

HOWTO

You will need to fold the plumber tape piece into 2 little pieces and fit it on the hose clamp and clamp it with some type of clamping tool. The plumber tape has small holes and big holes. Make sure the when you are cutting it, the smaller hole is on the outside edge.

Next, get the two LEDs on opposite sides into one of the smaller holes. Fold the shorter side of the LEDs onto the hose clamp. This is the ground.

Next, hot glue while making sure that the longer side of the LED does not touch any metal. This is to isolate the pins from any metal.

Now solder on the 100 Ohm resistors onto the longer side of LEDs and hot glue it to isolate from any metal parts.

Get two wires and solder them onto the other ends of the resistors and hot glue it again for isolation.

Now solder the red wire of the 9V battery connector to the the two wires and hot glue them for isolation.

You are done! Hook up the whole thing onto your golf club or a pipe and power it up!

1 00

Swing Analysis

When the blue line is clearly outside the red line, your clubface is "open" at impact.

Likewise, when the red line is outside the blue line, your clubface is "closed at impact.

The ideal impact is when you can see the red and blue lines merge together near the impact like this one:

Zedomax DIY125 How to Make a Music Syncing Light Orb Alarm Clock!
26

1 01

Intro

Okay, we have seen some really cool Light Orbs while trying to make this Music Syncing Light Orb Alarm Clock. We started with Tod's creation and soon realize that 1 LED will not be bright enough in slightest light conditions though his Light Orb is tight let us say. So we checked out RGB lights at Hackedgadgets.com. Which is cool and uses 4 Red, 3 Green, and 3 Blue LEDs. Well during our google search for Light Orb HOWTOs, we came to the Ambient Devices schematic and their technical notes. Well it says that with the right voltage, you don't need to use resistors.

During our breadboard testing, this proved to be costly. We went through about 20 nice High output LEDs trying to match the forward voltage of LEDs... (Alan, we need more red and green LEDs...hehe) Well, we tried all kinds of combinations including 3, 4, 5, and 6 LEDs per color. In the end, we found that 100 Ohms with 4 LEDs in series worked pretty well for all the LEDs regardless of their color and forward voltage. Since we wanted this project to be used with various LEDs, we decided to KISS (Keep It Simple Stupid) our way to the end. After we made the actual prototype and put the Orb on top, The 4 LEDs in series worked great even in lots of light. So best thing I think here is to test your LEDs on a breadboard first before soldering them. Even if the rated voltage of the LED says it'd work, we found that sometimes logic does not always work. Burn test your LEDs at least for 20 minutes and make sure they are still working before soldering anything... With that squared away, let's get back to DIY hacking business here. We wanted to create a Light Orb that would be a mix of Light Orb, some cheap Piezo music, and an alarm clock. We figured these would do very good Christmas presents for our friends and family.

1 02

Parts List

1 Perry Ellis Drawer from Ross $10 1 Light Orb thingee from Home Depot $9 1 CB280 $43 1 CB280 Mini-Proto Board $24 1 CLCD420B $49 2 IO Tact Switch $6 for 2 1 12V Adaptor $9 1 4-pin male connector for LCD connection $1.15 4 Red High Output LEDs $ 0.80 for 4 4 Green High Output LEDs $ 1.00 for 4 4 Blue High Output LEDs $1.00 for 4 3 50 to 150 Ohm resistors

(We used 100 Ohm resistors but you could probably use anywhere between 50 to 150 Ohm resistors)

5 4.7K Ohm resistors $ 0.99 for 100 3 2N3904 transistors $ 0.07 for 10 1 Piezo $3.96

Total Cost: Light Orb: about $80 Light Orb with Alarm Clock Function: about $140

1 03

Light Orb Schematics

(Yes, I had to goto a Christmas party, so here's a rough sketch!)

1 04

Build the CB280 Mini Proto-Board

First, you will need to build a CB280 Mini Proto-Board. Here's the HOWTO: CB280_Proto-Board_Solder_and_Assembly_HOWTO

1 05

Light Orb Mods

First, get the 3 4.7K resistors soldered onto I/O labels P5, P6, P7, and to empty holes as shown here:

Get one of your 2N3904 transistors and solder it on like shown here:

Solder on 2 more transistors:

Solder on 3 100 Ohm resistors to the right side of the resistors as shown here:

You can connect one end of the resistors to the right pin of the transistors as shown here:

Solder on your 4 Red LEDs in series from the 100 Ohm resistor:

Solder on your 4 Green LEDs in series and your 4 Blue LEDs in series too:

You can use one of the LEDs in series pins to connect to the other end of LEDs in series. So connect ground of LED row 1 to LED row 2 and connect ground of LED row 2 to LED row 3.

Splice some wire so it will fit the transistors like shown here and wire all the transistors on the back of the proto-board. This will all go to ground so wire the end to ground.

Solder the 4.7K Ohm resistor coming from P5 to middle pin of the first transistor.

Solder a wire from the 4.7K Ohm resistor on the P6 to middle pin of the second transistor.

Solder a wire from the the 4.7K Ohm resistor on the P7 to middle pin of the third transistor.

Now connect from the end of the LEDs to the DC Jack Positive point, 12V. (We can supply 9 to 24V, but we will use a 12V adaptor here)

Connect a 12V DC adaptor to your Proto-Board and see if it powers up. Download the program to your CB280. The Program source code is at the end of this HOWTO.

Put a Orb on top of the circuit and you should see colors!

Now if you got to this point and you don't want alarm clock function, you can stop here. But if you want to add the alarm function keep going.

1 06

Alarm Clock Mods

Okay, you will need some type of desk drawer thingee or something like it.

Disassemble everthing:

You can take out the center divide with a screwdriver like this:

You should get something like this:

Cut the bottom board you took out earlier so it will fit the frame on top.

Put one of the cut board on top and your proto-board on it.

Make a hole where you will get your LCD cable and some LEDs through:

Solder on the 4pin connector male onto the bottom of the proto-board and you will get something like this:

Solder on 3 Blue LEDs on the bottom of the proto-board next to the male connector:

Solder on a 100 Ohm resistor from the end of the 3 Blue LEDs to ground:

Connect the 4-pin connector to 5V and ground:

Solder on two 4.7K Ohm to P8 and P9 to 5V. This is for the I2C line for the LCD. You need 4.7K Pull-up resistors for the data lines SCL and SDA.

Now connect SCL and SDA to the 4-pin connector and you are almost ready to goto your Christmas party.

Connect the LCD and power it on! (My gf is getting mad becaz of this project but I am almost finshed!!!)

Now connect 2 wires from the bottom of the proto-board on P10 and P11. These will be connected to our pushswitches (IO tact switch) .

Here's the IO Tact switches that we will embedd onto our drawer thingee:

Connect the Ground and 5V together on the back of the IO Tact switches:

Drill some holes and fit them on your other half of top board. You can hot-glued them on like we did:

You should have the 4 lines coming from the bottom of your proto-board for the IO Tact switches:

Pull those wires through the holes and wire them to your IO Tact switches:

Hot-glue your LCD on to the frame:

Use screws to screw on the proto-board to the top board:

Hot glue the top boards to the frame and hot glue anything that's not:

Power it on and see if it's working...

You can use a piece of binder like we did to cover over the LEDs, so they will diffuse and mix colors!

1 07

Finished Pictures

1 08

Source Code

We didn't really have time to finish my project all the way but it works for now... We will have to add some more features next year. Merry Christmas!
Const Device = CB280 'Define speed for songs 'Set to higher for slower song speed and lower for faster song speed #define DELAYTIME 100 'Set delay time for Slow mode #define sdelay 10 Dim num As Byte 'PWM3, Song and frequency declarations Dim oct(9) As String *80 Const Single NOTES= (16.35,17.32,18.35,19.45,20.60,21.83,23.12, 24.50, 25.96, 27.50,29.14, 30.87) 'Octave 0 Const Single BLUES= (16.35,19.45,21.83,23.12,24.50,29.14) 'Jungle Bells Octave 5 oct(0)="O5,E2,E2,E4,E2,E2,E4,E2,G2,C3,D1,E8,F2,F2,F3,F1!" oct(1)="O5,F2,E2,E2,E1,E1,E2,D2,D2,E2,D4,G4,E2,E2,E4,E2,E2,E4,E2,G2,C3,D1,E8!" oct(2)="O5,F2,F2,F3,F1,F2,E2,E2,E1,E1,G2,G2,F2,D2,C8!" 'Jungle Bells Octave 6 oct(3)="O6,E2,E2,E4,E2,E2,E4,E2,G2,C3,D1,E8,F2,F2,F3,F1!" oct(4)="O6,F2,E2,E2,E1,E1,E2,D2,D2,E2,D4,G4,E2,E2,E4,E2,E2,E4,E2,G2,C3,D1,E8!" oct(5)="O6,F2,F2,F3,F1,F2,E2,E2,E1,E1,G2,G2,F2,D2,C8!" 'Jungle Bells Octave 4 oct(6)="O4,E2,E2,E4,E2,E2,E4,E2,G2,C3,D1,E8,F2,F2,F3,F1!" oct(7)="O4,F2,E2,E2,E1,E1,E2,D2,D2,E2,D4,G4,E2,E2,E4,E2,E2,E4,E2,G2,C3,D1,E8!" oct(8)="O4,F2,F2,F3,F1,F2,E2,E2,E1,E1,G2,G2,F2,D2,C8!" 'Period for PWM #define PeriodL 256 'Light RGB declarations Dim ct As Integer, ct2 As Byte, ct3 As Byte

Dim Dim Dim Dim Dim Dim

status1 As Byte, status2 As Byte, status3 As Byte Arrow As Byte SoundMode As Byte AlarmColor As Byte AlarmPosition As Byte TimePosition As Byte

SoundMode=3 AlarmColor=0 Arrow=1 AlarmPosition=0 TimePosition=0 Dim sec As Byte, min As Byte, hr As Byte Dim sec2 As Byte, min2 As Byte, hr2 As Byte Dim AlarmHr As Byte, AlarmMin As Byte 'Set default alarm to 6 AM. AlarmHr=6 AlarmMin=0 Dim SleepTime As Integer Dim Sleep As Byte Dim MenuMode As Byte SleepTime= 60 * 30 'Set default Sleep time to 30 minutes it would be 60 * 30 seconds MenuMode=0 'Main Menu Sleep=0 'PWM0, PWM1, PWM2, and PWM3 correspond to P5, P6, P7, and P19 of CB280 Output 5 Output 6 Output 7 Output 19 'Pushbutton inputs P10 and P11, set them to inputs Input 10 Input 11 'Reset Variables ct=200 ct2=0 ct3=0 status1=0 status2=0 status3=0 Red 0 Green 0 Blue 0

'

PlayString oct(2) Set Display 2,0,0,128 Cls Delay 200 Locate 0,0 Print "Zedomax Light Orb" Locate 5,1 Print "Alarm Clock" Delay 800 MainMenu

On Timer(10) Gosub here

Do 'Alarm 1000 'If Arrow at Mode If SoundMode=0 Then Pwmoff 3 Pwmoff 0 Pwmoff 1 Pwmoff 2 Elseif SoundMode=1 Then 'Play Jingle Bells For ct=0 To 8 PlayString oct(ct) Next Elseif SoundMode=2 Then RunBluesRandom Elseif SoundMode=3 Then Slow End If

' ' 'Slow

PlayString oct(1) Next

Loop here: PrintTime 0 If hr=AlarmHr And min=AlarmMin And sec=0 Then SoundMode=3 End If If Sleep=1 Then Locate 0,1 Print " " Locate 0,1 Print Dec SleepTime, " seconds left..." End If If In(10)=0 Then Debug "10!",Cr MaxBEEP Delay 100 If MenuMode=0 Then Locate 15,Arrow Print " " Incr Arrow If Arrow=4 Then Arrow=1 PrintArrow Elseif MenuMode=1 Then Locate 0,1 Print " " Locate 0,1 Print Dec SleepTime, " seconds left..." SoundMode=3 Sleep=1 MenuMode=2

Elseif MenuMode=2 Then Sleep=0 MenuMode=0 SoundMode=0 MainMenu Elseif MenuMode=3 Then If AlarmPosition =0 And TimePosition=0 Then Locate 15,Arrow Print " " If Arrow=1 Then Arrow=3 Elseif Arrow=3 Then Arrow=1 End If PrintArrow Elseif AlarmPosition=1 Then Incr AlarmHr Locate 0,2 Print Dp(AlarmHr,2,1) Elseif AlarmPosition=2 Then Incr AlarmMin Locate 3,2 Print Dp(AlarmMin,2,1) Elseif TimePosition=1 Then Incr hr Timeset 12,hr PrintTime 1 Elseif TimePosition=2 Then Incr min Timeset 11,min PrintTime 1 End If End If

Elseif In(11)=0 Then Debug "11!",Cr MaxBEEP Delay 100 If MenuMode=0 Then If Arrow=1 Then Incr SoundMode If SoundMode=4 Then SoundMode=0 'If Arrow at Sleep Elseif Arrow=2 Then Cls Csroff PrintTime 1 Locate 0,1 Print Dec SleepTime/60 Arrow=1 PrintArrow MenuMode=1 Elseif Arrow=3 Then Cls Csroff PrintTime 1

Locate 0,2 Print Dp(AlarmHr,2,1),":",Dp(AlarmMin,2,1),":00" Locate 0,1 Print "Set Time" Locate 0,3 Print "Set Alarm" 'Set MenuMode to Alarm and Time setting MenuMode=3 Arrow=1 PrintArrow End If Elseif MenuMode=1 Then If Arrow=1 Then Locate 0,1 Print " " Locate 0,1 SleepTime=SleepTime+60 Print Dec SleepTime/60 End If Elseif MenuMode=3 Then If Arrow=3 Then Incr AlarmPosition If AlarmPosition=1 Then Locate 0,3 Print " Locate 0,3 Print "||" Elseif AlarmPosition=2 Then Locate 0,3 Print " " Locate 3,3 Print "||" Elseif AlarmPosition=3 Then AlarmPosition=0 MenuMode=0 MainMenu End If Elseif Arrow=1 Then Incr TimePosition If TimePosition=1 Then Locate 0,1 Print " Locate 0,1 Print "||" Elseif TimePosition=2 Then Locate 0,1 Print " " Locate 3,1 Print "||" Elseif TimePosition=3 Then TimePosition=0 MenuMode=0 MainMenu End If End If End If End If 'Display current time only if seconds has changed

"

"

Return Do If status1=0 And ct<255 Or ct<50Then status1=0 Incr ct Else status1=1 Decr ct End If If status2=0 And ct2<255 Or ct2<50 Then status2=0 Incr ct2 Else status2=1 Decr ct2 End If If status3=0 And ct3<255 Or ct3<50 Then status3=0 Incr ct3 Else status3=1 Decr ct3 End If

Red ct Blue ct2 Green ct3

Loop

End Sub MainMenu() Cls Csroff PrintTime 1 Locate 0,1 Print "Mode" Locate 0,2 Print "Sleep" Locate 0,3 Print "Set Alarm/Time" Locate 15,Arrow Print "<-" End Sub Sub PrintArrow() Locate 15,Arrow Print "<-" End Sub

Sub PrintTime(pmode As Byte) sec=Time(10) min=Time(11) hr=Time(12) If hr=24 Then Timeset 12,0 hr=0 End If If pmode=0 Then If hr<>hr2 Then Locate 0,0 Print Dp(hr,2,1), ":" Elseif min <> min2 Then Locate 3,0 Print Dp(min,2,1), ":" Elseif sec2 <> sec Then If Sleep=1 Then If SleepTime=0 Then Sleep=0 SoundMode=0 End If If SleepTime>0 Then Decr SleepTime End If Locate 6,0 Print Dp(sec,2,1) End If Else Locate 0,0 Print Dp(hr,2,1), ":",Dp(min,2,1), ":",Dp(sec,2,1) End If hr2=hr min2=min sec2=sec End Sub

Sub Blue(DutyValue As Integer) 'Debug "Blue DutyValue: ", Pwm 0,DutyValue,PeriodL End Sub Sub Green(DutyValue As Integer) 'Debug "Green DutyValue: ", Pwm 1,DutyValue,PeriodL End Sub Sub Red(DutyValue As Integer) ' Debug "Red DutyValue: ", Pwm 2,DutyValue,PeriodL End Sub

Dec DutyValue,Cr

Dec DutyValue,Cr

Dec DutyValue,Cr

Sub RGB() For ct=0 To 1024 Red ct

Next For ct=1024 To 1 Step -1 Red ct Next For ct=0 To 1024 Blue ct Next For ct=1024 To 1 Step -1 Blue ct Next

For ct=0 To 1024 Green ct Next For ct=1024 To 1 Step -1 Green ct Next End Sub Sub Alarm(mode As Byte) Select Case mode Case 0 Green 0 Blue 255 Case 1 Blue 0 Red 255 Case 2 Red 0 Green 255 Case 3 Blue 255 Red 255 Green 0 Case 4 Green 255 Red 255 Blue 0 Case 5 Green 255 Blue 255 Red 0 End Select End Sub

Sub Slow()

For ct=0 To 255 Blue ct Wait sdelay If SoundMode=0 Then Exit For

Next

For ct=0 To 255 Red ct Wait sdelay If SoundMode=0 Then Exit For Next For ct=255 To 10 Step -1 Blue ct Wait sdelay If SoundMode=0 Then Exit For Next

For ct=0 To 255 Green ct Wait sdelay If SoundMode=0 Then Exit For Next For ct=255 To 10 Step -1 Red ct Wait sdelay If SoundMode=0 Then Exit For Next For ct=0 To 255 Blue ct Wait sdelay If SoundMode=0 Then Exit For Next For ct=0 To 255 Red ct Wait sdelay If SoundMode=0 Then Exit For Next For ct=255 To 10 Step -1 Blue ct Wait sdelay If SoundMode=0 Then Exit For Next For ct=255 To 10 Step -1 Red ct Wait sdelay If SoundMode=0 Then Exit For Next For ct=255 To 10 Step -1 Green ct Delay sdelay If SoundMode=0 Then Exit For Next

End Sub

'Parse music notes and play them on piezo

Sub Dim Dim Dim

PlayString(PlayNotes As String * 100) a As Byte k As Integer CurrentOctave As Byte

CurrentOctave=0 a=0 k=PlayNotes_A(0)

Do Until k=33 If SoundMode <> 1 Then Exit Do If(k=111 Or k=79) Then 'if O or o for octave Change Incr a k=PlayNotes_A(a) Debug "OCTAVE CHANGED TO: ", k, Cr k=k-48 CurrentOctave=k Elseif(k=67 Or k=99) Then Debug k Incr a k=PlayNotes_A(a) If(k=35) Then '# Debug "#" Incr a k=PlayNotes_A(a) 'if C

If(k>=48 And k<=57) Then ' Between 0 and 9 Debug k k= k-48 PlayNote 1, k * DELAYTIME,CurrentOctave End If Elseif (k>=48 And k<=57) Then ' if k between 0 and 9 Debug k k= k-48 PlayNote 0, k* DELAYTIME, CurrentOctave End If Elseif(k=68 Or k=100) Then Debug "D" Incr a k=PlayNotes_A(a) If(k=35) Then '# Debug "#" Incr a k=PlayNotes_A(a) If(k>=48 And k<=57) Then ' Between 0 and 9 Debug k k=k-48 PlayNote 3, k * DELAYTIME,CurrentOctave End If Elseif (k>=48 And k<=57) Then ' if k between 0 and 9 Debug k k= k-48 PlayNote 2, k* DELAYTIME, CurrentOctave End If

Elseif(k=69 Or k=101) Then Debug "E" Incr a k=PlayNotes_A(a) If(k>=48 And k<=57) Then ' Between 0 and 9 Debug k k= k-48 PlayNote 4, k * DELAYTIME,CurrentOctave End If End If Elseif(k=70 Or k=102) Then Debug "F" Incr a k=PlayNotes_A(a) If(k=35) Then '# Debug "#" Incr a k=PlayNotes_A(a) If(k>=48 And k<=57) Then ' Between 0 and 9 Debug k k=k-48 PlayNote 6, k * DELAYTIME,CurrentOctave End If Elseif (k>=48 And k<=57) Then ' if k between 0 and 9 Debug k k= k-48 PlayNote 5, k* DELAYTIME, CurrentOctave End If

Elseif(k=71 Or k=103) Then Debug "G" Incr a k=PlayNotes_A(a) If(k=35) Then '# Debug "#" Incr a k=PlayNotes_A(a) If(k>=48 And k<=57) Then ' Between 0 and 9 Debug k k=k-48 PlayNote 8, k * DELAYTIME,CurrentOctave End If Elseif (k>=48 And k<=57) Then ' if k between 0 and 9 Debug k k= k-48 PlayNote 7, k* DELAYTIME, CurrentOctave End If Elseif(k=65 Or k=97) Then Debug "A" Incr a k=PlayNotes_A(a) If(k=35) Then '# Debug "#"

Incr a k=PlayNotes_A(a) If(k>=48 And k<=57) Then ' Between 0 and 9 Debug k k=k-48 PlayNote 10, k * DELAYTIME,CurrentOctave End If Elseif (k>=48 And k<=57) Then ' if k between 0 and 9 Debug k k= k-48 PlayNote 9, k* DELAYTIME, CurrentOctave End If Elseif(k=66 Or k=98) Then Debug "B" Incr a k=PlayNotes_A(a) If (k>=48 And k<=57) Then ' if k between 0 and 9 Debug k k= k-48 PlayNote 11, k* DELAYTIME, CurrentOctave End If End If Incr a k=PlayNotes_A(a) If k=44 Then 'For commas Incr a k=PlayNotes_A(a) End If Loop End Sub Sub Dim Dim Dim PlayNote(ThisNote As Byte,PlayTime As Integer, Octave As Byte) tsingle As Single period As Integer multiply As Byte

tsingle=NOTES(ThisNote) Debug " Octave: ", Dec Octave If Octave>0 Then For multiply=1 To Octave tsingle=tsingle * 2 Next End If Debug " Freq: ", Float tsingle period =GetWidth(tsingle) Debug " Period: ", Dec period,Cr '---Incr AlarmColor If AlarmColor>5 Then AlarmColor=0 Alarm AlarmColor '--Pwm 3,period/2,period

Delay PlayTime Pwmoff 3 End Sub

'Find (Width)Period of Frequency! Function GetWidth(Frequency As Single) As Integer Dim a As Single a=4/(0.000001*1.735*Frequency) a=a-1 GetWidth=Floor(a) End Function

Sub RunBluesRandom() Dim tsingle As Single Dim Period As Integer Dim bluesrand As Byte num=Rnd(3) mod 6 rnd() Debug Dec num,Cr tsingle=BLUES(num) bluesrand=Rnd(0) Debug "RANDDDD: ",Dec bluesrand,Cr If bluesrand <150 Then tsingle=tsingle * 16 Else tsingle=tsingle * 32 End If Period=GetWidth(tsingle) Debug "Result: ",Dec Period,Cr,Cr '---Incr AlarmColor If AlarmColor>5 Then AlarmColor=0 Alarm AlarmColor '--Pwm 3,(Period/2),Period If Rnd(0) <8000 Then Delay 400 Else Delay 200 End If End Sub 'Cool BEEP noise function for PWM3 Piezo Sub MaxBEEP() Pwmoff 3 'Turn off PWM3 Dim SJ As Byte ' Max's BLUES Solo!!!

'Get random values by using

For SJ = 0 To 50 Reverse 19 Udelay 70 Reverse 19 Next For SJ = 0 To 80 Reverse 19 Udelay 40 Reverse 19 Next End Sub

Zedomax DIY127 - How to Make an Ethernet Controlled Color Organ!


27

For this weekend, we will show you how to make an ethernet controlled color organ that can be applied for some kind of stage lighting. We will be using the party light we made and simply plugin the MaxPORT module to the serial port of the CuSB22R. Then all you need to do is make sure to plug in a LAN wire to it. First you will need to download this MaxPORT package. This package includes the custom MaxPORT firmware you can load to the MaxPORT for custom firmware to allow downloading a program over ethernet. It also includes an open-source VB program you can customize to your application. Download Maxport v.1.3.0 package After you unzip the package, you will find a setup file, MaxportSetup.exe. Run this and install the MaxPORT program into your computer. The other files in the Zip file includes the Visual Basic source code for the MaxPORT program and some party light programs you can try including the ethernet controlled color organ. Under Test Programs you will see two file:
partyautomatic.cul - This one is the party light program from our [http://zedomax.com/blog/zedomax-diy-106-make-a-computer-controlled-party-light-part-ii/ previous DIY] partylightethernet.cul - This one is the ethernet controlled color organ program.

First, you will need to make the party light, so refer to our Party Light DIY. Then, run the MaxPORT program. You should see the following screen:

Click on Search and find the MaxPORT that's on the network:

Once you found it, highlight it.

We need to load the custom MaxPORT Firmware in order to do some downloads, do click on, "Download XPORT Firmware" button and find the maxport130.rom file which is included in the zip file you downloaded.

It should download and the MaxPORT will reset itself. So click on "Search" again after about 30 seconds.

Next, select the correct IP address for your MaxPORT again and then select the "CUBLOC Object File Downloader". Select the file "partylightethernet.obj" and click OK.

After you download, click on "Set Debug On" and you will see a little debug window pop up.

Click on the Top message field and type "asdjkl", and you will see your AC lights turn On according to your pressed keys.

1 09

Pics:

Zedomax DIY128 - HOW TO Make a Glowing Heart LED Night Light!


28

I was at my local Dollar Store the other day and when I saw this Heart shaped Touch Light, I had to hack one for my gf. Here's a quick hack on how to make a regular Touch Light and make it into a Glowing Heart Night Light.

1 10

Parts List

Touch Light from local Dollar Store: $1 CB220 Proto Board: $5 CB220 Module: $34 12V Adaptor: $9 11 RED High Output LEDs : about $5 Soldering stuff screw driver Total Cost for parts: $54 Video on YouTube

1 11

HOWTO

1) First you get the parts ready...

2) Unscrew the screws on the Tough Light and open it up.

3) Build the Proto-board and then build the circuit.

4) Get rid of the bulb.

5) You can use a 12V adaptor to power the thing or use 9V battery too.

6) Cut the end of the adaptor and slide it through the holes in the Heart Touch Light.

7) Connect the cut lines to the DC Jack of the protoboard

8) Connect the DC Adaptor ends as shown above.

9) Place the whole board on top.

10) Get a piece of plastic or make a little film piece using scotch tape.

11) tape it nice so the board stays in tact. 12) Download this program to the CUBLOC CB220 module:
Const Device = CB220 Dim Duty As Integer Dim direction As Byte Dim onoff As Byte Dim ct As Byte onoff=0 Output 5 Output 6 Output 7 Duty=0 direction=0 On Timer(5) Gosub here Do Loop here: If direction=0 Then Duty=Duty+25 Else Duty=Duty-25 End If Pwm 0,Duty,1024 Pwm 1,Duty,1024

Pwm 2,Duty,1024

If Duty>1024 And direction=0 Then direction=1 If Duty<5 And direction=1 Then direction=0 For ct=0 To 15 onoff = onoff Xor 1 Out 0,onoff Out 1,onoff Out 2,onoff Out 3,onoff Out 4,onoff Wait 50 Next End If

Return

12) Screw the whole Touch Light together and test it out!

Você também pode gostar