Notice. New forum software under development. It's going to miss a few functions and look a bit ugly for a while, but I'm working on it full time now as the old forum was too unstable. Couple days, all good. If you notice any issues, please contact me.
|
Forum Index : Microcontroller and PC projects : Controlling lights
Author | Message | ||||
CircuitGizmos Guru Joined: 08/09/2011 Location: United StatesPosts: 1425 |
Here is something I made a while back. This is a light controller made using Maximite technology. This is definitely a one-time project kludged together until it works and then forgotten. This has been running for months. Here is a picture: I'm presenting it here to show that the Maximite can be the brains of a project that just sits there all day working. Doing its job. The kludge in the picture: PowerLinc serial x10 interface. They don't make these anymore. It provides 12V for the project. 1 1x24 LCD A bit of protoboard with three buttons and a switch. An ALMOST-CGMMSTICK. This one was a prototype. May as well use it. Interface chips to go from 3V to 5V for the LCD. I wrote code to get it to work, but no refinement for elegance. ' I/O init SETPIN 1, 8 PIN(1) = 1 SETPIN 2, 8 PIN(2) = 1 SETPIN 3, 8 PIN(3) = 1 SETPIN 4, 8 PIN(4) = 1 SETPIN 5, 8 PIN(5) = 1 SETPIN 6, 8 PIN(6) = 1 SETPIN 7, 8 PIN(7) = 1 SETPIN 8, 8 PIN(8) = 1 SETPIN 9, 8 PIN(9) = 1 SETPIN 10, 8 PIN(10) = 1 SETPIN 11, 2 SETPIN 12, 2 SETPIN 13, 2 SETPIN 17, 2 SETPIN 20, 8 PIN(20) = 1 Open "com1: 9600, OC" As #1 ' Reset and init LCD LCDRESET LCDCOMMAND &h1C LCDCOMMAND &h14 LCDCOMMAND &h28 LCDCOMMAND &h4F LCDCOMMAND &hE0 LCDCOMMAND &h01 TSTR$ = TIME$ Light5 = 0 Light6 = 0 Light7 = 0 loopy: ProgRun = Pin(17) if ProgRun = 0 then GOTO PROG TSTR$ = TIME$ LCDCOMMAND &h01 LCDDATA ASC(MID$(TSTR$, 1, 1)) LCDDATA ASC(MID$(TSTR$, 2, 1)) LCDDATA ASC(MID$(TSTR$, 3, 1)) LCDDATA ASC(MID$(TSTR$, 4, 1)) LCDDATA ASC(MID$(TSTR$, 5, 1)) LCDDATA ASC(MID$(TSTR$, 6, 1)) LCDDATA ASC(MID$(TSTR$, 7, 1)) LCDDATA ASC(MID$(TSTR$, 8, 1)) LCDDATA ASC(" ") LCDDATA ASC("L") LCDDATA ASC("i") LCDDATA ASC("g") LCDDATA ASC("h") LCDDATA ASC("t") LCDDATA ASC(":") LCDDATA ASC(" ") IF Light5 = 0 THEN LCDDATA ASC(" ") ELSE LCDDATA ASC("5") ENDIF LCDDATA ASC(" ") IF Light6 = 0 THEN LCDDATA ASC(" ") ELSE LCDDATA ASC("6") ENDIF LCDDATA ASC(" ") IF Light7 = 0 THEN LCDDATA ASC(" ") ELSE LCDDATA ASC("7") ENDIF ' Morning on IF TIME$ = "06:30:00" then Light5On IF TIME$ = "06:31:00" then Light5On IF TIME$ = "06:32:00" then Light5On IF TIME$ = "07:00:00" then Light7On IF TIME$ = "07:01:00" then Light7On IF TIME$ = "07:02:00" then Light7On ' Morning off IF TIME$ = "07:30:00" then Light5Off IF TIME$ = "07:31:00" then Light5Off IF TIME$ = "07:32:00" then Light5Off IF TIME$ = "07:33:00" then Light7Off IF TIME$ = "07:34:00" then Light7Off IF TIME$ = "07:35:00" then Light7Off ' Evening on IF TIME$ = "21:00:00" then Light5On IF TIME$ = "21:02:00" then Light5On IF TIME$ = "21:04:00" then Light5On IF TIME$ = "21:01:00" then Light7On IF TIME$ = "21:03:00" then Light7On IF TIME$ = "21:05:00" then Light7On ' Evening off IF TIME$ = "23:30:00" then Light5Off IF TIME$ = "23:31:00" then Light5Off IF TIME$ = "23:32:00" then Light5Off IF TIME$ = "23:33:00" then Light7Off IF TIME$ = "23:34:00" then Light7Off IF TIME$ = "23:35:00" then Light7Off pause 300 GOTO loopy PROG: TSTR$ = TIME$ LCDCOMMAND &h01 LCDDATA ASC("S") LCDDATA ASC("e") LCDDATA ASC("t") LCDDATA ASC(" ") LCDDATA ASC("t") LCDDATA ASC("i") LCDDATA ASC("m") LCDDATA ASC("e") LCDDATA ASC(":") LCDDATA ASC(" ") LCDDATA ASC(MID$(TSTR$, 1, 1)) LCDDATA ASC(MID$(TSTR$, 2, 1)) LCDDATA ASC(MID$(TSTR$, 3, 1)) LCDDATA ASC(MID$(TSTR$, 4, 1)) LCDDATA ASC(MID$(TSTR$, 5, 1)) Hpin = Pin(13) IF Hpin = 0 THEN SetHour = VAL(MID$(TSTR$, 1, 1)) * 10 SetHour = Sethour + VAL(MID$(TSTR$, 2, 1)) SetHour = SetHour + 1 If SetHour = 25 THEN SetHour = 0 ENDIF TIME$ = Str$(SetHour) + MID$(TSTR$, 3, 1) + MID$(TSTR$, 4, 1) + MID$(TSTR$, 5, 1) ENDIF Mpin = Pin(12) IF Mpin = 0 THEN SetMin = VAL(MID$(TSTR$, 4, 1)) * 10 SetMin = SetMin + VAL(MID$(TSTR$, 5, 1)) SetMin = SetMin + 1 If SetMin = 60 THEN SetMin = 0 ENDIF TIME$ = MID$(TSTR$, 1, 1) + MID$(TSTR$, 2, 1) + MID$(TSTR$, 3, 1) + Str$(SetMin) ENDIF pause 150 GOTO loopy END Sub LCDRESET PIN(20) = 0 PAUSE 100 PIN(20) = 1 PAUSE 100 PIN(20) = 0 PAUSE 100 End Sub Sub LCDDATA (valu) PIN(9) = 0 valu = (valu XOR &hFF) PIN(1) = valu AND &B00000001 PIN(2) = valu AND &B00000010 PIN(3) = valu AND &B00000100 PIN(4) = valu AND &B00001000 PIN(5) = valu AND &B00010000 PIN(6) = valu AND &B00100000 PIN(7) = valu AND &B01000000 PIN(8) = valu AND &B10000000 PIN(10) = 1 PAUSE 1 PIN(10) = 0 PAUSE 1 PIN(10) = 1 PAUSE 1 End Sub Sub LCDCOMMAND (valu) PIN(9) = 1 valu = (valu XOR &hFF) PIN(8) = valu AND &B10000000 PIN(7) = valu AND &B01000000 PIN(6) = valu AND &B00100000 PIN(5) = valu AND &B00010000 PIN(4) = valu AND &B00001000 PIN(3) = valu AND &B00000100 PIN(2) = valu AND &B00000010 PIN(1) = valu AND &B00000001 PIN(10) = 1 PAUSE 10 PIN(10) = 0 PAUSE 10 PIN(10) = 1 PAUSE 10 End Sub Sub Light5On Light5 = 1 Print #1, Chr$(&h02); Pause 5 Print #1, Chr$(&h63); Print #1, Chr$(&h4B); Print #1, Chr$(&h42); Print #1, Chr$(&h45); Print #1, Chr$(&h41); Pause 1000 End Sub Sub Light5Off Light5 = 0 Print #1, Chr$(&h02); Pause 5 Print #1, Chr$(&h63); Print #1, Chr$(&h4B); Print #1, Chr$(&h42); Print #1, Chr$(&h47); Print #1, Chr$(&h41); Pause 1000 End Sub Sub Light6On Light6 = 1 Print #1, Chr$(&h02); Pause 5 Print #1, Chr$(&h63); Print #1, Chr$(&h4B); Print #1, Chr$(&h52); Print #1, Chr$(&h45); Print #1, Chr$(&h41); Pause 1000 End Sub Sub Light6Off Light6 = 0 Print #1, Chr$(&h02); Pause 5 Print #1, Chr$(&h63); Print #1, Chr$(&h4B); Print #1, Chr$(&h52); Print #1, Chr$(&h47); Print #1, Chr$(&h41); Pause 1000 End Sub Sub Light7On Light7 = 1 Print #1, Chr$(&h02); Pause 5 Print #1, Chr$(&h63); Print #1, Chr$(&h4B); Print #1, Chr$(&h4A); Print #1, Chr$(&h45); Print #1, Chr$(&h41); Pause 1000 End Sub Sub Light7Off Light7 = 0 Print #1, Chr$(&h02); Pause 5 Print #1, Chr$(&h63); Print #1, Chr$(&h4B); Print #1, Chr$(&h4A); Print #1, Chr$(&h47); Print #1, Chr$(&h41); Pause 1000 End Sub The code goes onto drive A: (internal) as autorun.bas I change the on/off times during the year as I see fit. The switch is for set time in one position and run in the other. Buttons are for setting time. X10 adapter accepts odd serial commands. They are repeated to make sure the signalling happens. Not posting a schematic or any detailed info - this is more or less not a reproducible kludge. But I'm open to answering questions if that helps anyone's projects. Micromites and Maximites! - Beginning Maximite |
||||
Print this page |