Skip to content

Instantly share code, notes, and snippets.

James Bruce jamesabruce

Block or report user

Report or block jamesabruce

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View newping_demo.ino
#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);
View Newsletter Subscription sample form
<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">
View POVwriter.ino
// 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;
@jamesabruce
jamesabruce / detect.py
Created Aug 19, 2015
OpenHAB on Raspberry Pi Tutorial: Detect User Presence via Bluetooth, report to RESTful OpenHAB interface
View detect.py
#!/usr/bin/python
import bluetooth
import time
import requests
from requests.exceptions import ConnectionError
payload =''
while True:
@jamesabruce
jamesabruce / detect.py
Created Jul 14, 2015
Detect user through Bluetooth demo, Python
View detect.py
#!/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 / mysensors_humidity_relay_nonblocking.ino
Created Dec 11, 2015
MySensors Example - Humidity and Relay with Non-blocking Loop
View mysensors_humidity_relay_nonblocking.ino
/**
* The MySensors Arduino library handles the wireless radio link and protocol
* between your home built sensors/actuators and HA controller of choice.
* The sensors forms a self healing radio network with optional repeaters. Each
* repeater and gateway builds a routing tables in EEPROM which keeps track of the
* network topology allowing messages to be routed to nodes.
*
* Created by Henrik Ekblad <henrik.ekblad@mysensors.org>
* Copyright (C) 2013-2015 Sensnology AB
* Full contributor list: https://github.com/mysensors/Arduino/graphs/contributors
@jamesabruce
jamesabruce / Philips Hue Candle Effect
Created Apr 4, 2015
High speed, flickering candle bulb effect for any number of Philips Hue bulbs
View Philips Hue Candle Effect
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"
View thundercloud.ino
/*
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 / lock.py
Created Jul 14, 2015
DIY Proximity Lock v.01
View lock.py
#!/usr/bin/python
import bluetooth
import time
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BCM)
RELAY = 23
GPIO.setup(RELAY, GPIO.OUT)
View Arduino Sunrise Alarm Clock and Night Light by James Bruce
/*
* 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
*
*/
You can’t perform that action at this time.