Skip to content

Instantly share code, notes, and snippets.

View jamesabruce's full-sized avatar

James Bruce jamesabruce

  • Cornwall, UK
View GitHub Profile
/*
* Sunrise Alarm Clock and Night Light by James Bruce
* http://duinobits.com
* Initial setup requires you to reset the Arduino sometime in the evening.
* Set the hoursUntilSunrise relative to this time.
* eg, if you reset at 10pm, and want the sunrise to start at 6:30am,
* the value should be 8.5 - this will then be automatically changed to minutes for internal clock to function
*
*/
/*
Lighting Cloud Mood Lamp By James Bruce
View the full tutorial and build guide at http://www.makeuseof.com/
Sound sampling code originally by Adafruit Industries. Distributed under the BSD license.
This paragraph must be included in any redistribution.
*/
#include <Wire.h>
#include "FastLED.h"
@jamesabruce
jamesabruce / Philips Hue Candle Effect
Created April 4, 2015 07:22
High speed, flickering candle bulb effect for any number of Philips Hue bulbs
set HUB to "192.168.1.216" --change for your bridge IP
set USER to "newdeveloper"
repeat
repeat with bulb from 1 to 2 -- Change if you have more bulbs or want to use a subset
set hue to (random number from 5000 to 12750)
set sat to (random number from 150 to 255)
set bri to (random number from 50 to 255)
set transitiontime to (random number from 1 to 3) -- Increase range for slower transitions
set query to "{\"sat\":" & sat & ",\"hue\":" & hue & ",\"bri\":" & bri & ",\"transitiontime\":" & transitiontime & "}"
set command to "curl --request PUT --data '" & query & "' http://" & HUB & "/api/" & USER & "/lights/" & bulb & "/state/ --connect-timeout 5"
@jamesabruce
jamesabruce / detect.py
Created July 14, 2015 16:52
Detect user through Bluetooth demo, Python
#!/usr/bin/python
import bluetooth
import time
while True:
print "Checking " + time.strftime("%a, %d %b %Y %H:%M:%S", time.gmtime())
result = bluetooth.lookup_name('78:7F:70:38:51:1B', timeout=5)
if (result != None):
print "User present"
@jamesabruce
jamesabruce / detect.py
Created August 19, 2015 11:53
OpenHAB on Raspberry Pi Tutorial: Detect User Presence via Bluetooth, report to RESTful OpenHAB interface
#!/usr/bin/python
import bluetooth
import time
import requests
from requests.exceptions import ConnectionError
payload =''
while True:
// how long each led stays on for
int delayTime = 1;
//how long between each
int charBreak = 3;
//how long to wait after the message is finished before it repeats
int resetTime = 20;
int LED1 = 2;
int LED2 = 3;
int LED3 = 4;
<form data-fv-framework="bootstrap" novalidate="novalidate" class="fv-form fv-form-bootstrap"><button type="submit" class="fv-hidden-submit" style="display: none; width: 0px; height: 0px;"></button>
<div class="items">
<div class="item">
<input type="hidden" name="topics[0][type]" value="category">
<input type="hidden" name="topics[0][id]" value="4893">
<input type="hidden" name="topics[0][checked]" value="0">
<label><div class="checker"><span><input name="topics[0][checked]" value="1" type="checkbox"></span></div><span>Smart Home</span></label>
</div>
<div class="item">
<input type="hidden" name="topics[1][type]" value="post_tag">
#include <NewPing.h>
//Tell the Arduino where the sensor is hooked up
NewPing sonar(12, 13);
long inches;
void setup() {
//Activate the serial monitor so you can see the output of the sensor
Serial.begin(9600);
@jamesabruce
jamesabruce / 4wd-robot-test.ino
Created December 17, 2015 10:18
First program for 4WD Arduino Robot Kit
// Motor A pins (enableA = enable motor, pinA1 = forward, pinA2 = backward)
int enableA = 11;
int pinA1 = 6;
int pinA2 = 5;
//Motor B pins (enabledB = enable motor, pinB2 = forward, pinB2 = backward)
int enableB = 10;
int pinB1 = 4;
int pinB2 = 3;
@jamesabruce
jamesabruce / flora-clutch.ino
Created March 10, 2016 10:02
Light-Up Clutch Demo of Element14 Flora Arduino Starter Kit
// things from the color sensor library
#include
#include "Adafruit_TCS34725.h"
/* Initialise with specific int time and gain values */
Adafruit_TCS34725 tcs = Adafruit_TCS34725(TCS34725_INTEGRATIONTIME_50MS, TCS34725_GAIN_4X);
// including things from light sensor library