December 8, 2014
The Home Automation system uses the racket language and Arduino micro controller to implement a system to automate lighting, heating, and cooling controls. Racket uses the host computers serial port communicate with the Arduino and send commands to turn on or off various lights and a simulated HVAC system. A simple GUI is used to allow for user interaction with the system.
- Data abstraction is used to provide access to and control of the LEDs on the Arduino.
- Message passing is used to send commands to the LEDS.
- Let and lambda are used in the GUI to provide functionality to the buttons.
- Type coercion is used in the GUI to convert ints to strings
- Cons cells are used to store the time for each object to turn on/off
External Technology and Libraries
- Firmata Library
- GUI Library
Favorite Lines of Code
- Alessandro Allen: This section of code runs a clock and displays the current date and time in the GUI
(define timer (new timer% [notify-callback (lambda () (set! date (seconds->date (current-seconds))) (set! hour (number->string (abs (- 12 (date-hour date))))) (set! minute (if (< (date-minute date) 10) (string-append "0" (number->string (date-minute date))) (number->string (date-minute date)))) (set! month (number->string (date-month date))) (set! day (number->string (date-day date))) (set! year (number->string (date-year date))) (set! time-string (string-append hour ":" minute)) (set! date-string (string-append month "/" day "/" year)) (send actual-date set-label date-string) (send actual-time set-label time-string))] [interval #f]))
- Brian Day:
#|----------------------------------------- HVAC - not 100% complete but is the object to control ac/furnace/fan -------------------------------------------|# (define (make-HVAC-obj name) (let* ([schedual #f] ;manual temp change only(overides current schedual until next schedualed time triggers) [time-morn (cons (cons 0 0) -1)]; time/temp ((12.00). 65) temp in F [time-afternoon (cons (cons 0 0) -1)] [time-evening (cons (cons 0 0) -1)] [time-night (cons (cons 0 0) -1)] [time-schedual (list time-morn time-afternoon time-evening time-night)] ;sets high/low for HVAC to kick on defaults to 2 degree dif [temp-range 2] [temp-on (lambda (x) (- x temp-range))]; prob dont need lambda??? [temp-off (lambda (x) (+ x temp-range))] [furnace (make-simple-device-obj 'furnace 11 OUTPUT_MODE)];shouldnt be hardcoded pin [fan (make-simple-device-obj 'fan 12 OUTPUT_MODE)];shouldnt be hardcoded pin [ac (make-simple-device-obj 'ac 13 OUTPUT_MODE)];shouldnt be hardcoded pin ;[thermostat (make-analog-obj 'therm); [slaves (list furnace fan ac)] ;complex device can have simple devices that are controled by it [inputs '()] ; can allow [device-obj (make-simple-device-obj name 0 0)]);not actually connected to pins (lambda (message) (cond [(eq? message 'get-slave) (λ (self sub-obj) sub-obj)] [(eq? message 'set-slave!) (λ (self slave state) ;(filter-map (λ (i) (if (eq? slave (ask i 'name))#t #f))slaves))];returns a list not what is wanted (map (λ (i) (if (eq? slave (ask i 'name));look for item in list with correct name (begin (ask i 'set-state! state) #t) #f ))slaves))] [(eq? message 'set-fan!) (λ (self state) (ask (ask self 'get-slave fan) 'set-state! state))] ;manual control only use 'set-temp-schedual! for automation [(eq? message 'set-temp!) (lambda (self) self)] [(eq? message 'set-temp-schedual!) (lambda (self ) self)] [(eq? message 'slaves) (lambda (self) slaves)] [else (get-method device-obj message)]) )))
This block of code reads in a regular expression and uses it to match against a pre-existing hash-map named
Technology Used Block Diagram
Git Hub ----> most up-to-date-code