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
@jamesabruce
jamesabruce / robot_with_ping.ino
Created Dec 19, 2015
Beginner Robot with Ping Sensor
View robot_with_ping.ino
#include <NewPing.h>
//Tell the Arduino where the sensor is hooked up
NewPing sonar(12, 13);
int enableA = 11;
int pinA1 = 6;
int pinA2 = 5;
int enableB = 10;
@jamesabruce
jamesabruce / 4wd-robot-test.ino
Created Dec 17, 2015
First program for 4WD Arduino Robot Kit
View 4wd-robot-test.ino
// 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 / 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
View outgoing webhook response that doesnt unfurl
{"text":"These posts are still doing well: <http://www.makeuseof.com/tag/control-philips-hue-lights-arduino-and-motion-sensor/> (1392) ... <http://www.makeuseof.com/tag/3-easy-ways-tablet-stand/> (1037) ... <http://www.makeuseof.com/tag/upgrade-ps4s-hard-drive/> (2966) ","unfurl_links": true}
View MQTT publishing DHT11 sensor on Arduino
/*
Basic MQTT example
*/
#include <SPI.h>
#include <Ethernet.h>
#include <PubSubClient.h>
// Our first sensor, a cheap DHT11 temperature and humidty sensor
#include <DHT.h>
@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 / 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)
@jamesabruce
jamesabruce / Control Philips Hue from Arduino Ethernet Shield
Created Apr 5, 2015
Example of using an Arduino with Ethernet shield to control Philips Hue, with PIR motion sensor on i/o pin 2.
View Control Philips Hue from Arduino Ethernet Shield
/*
Talking to Hue from an Arduino
By James Bruce (MakeUseOf.com)
Adapted from code by Gilson Oguime. https://github.com/oguime/Hue_W5100_HT6P20B/blob/master/Hue_W5100_HT6P20B.ino
*/
#include <SPI.h>
#include <Ethernet.h>
// Hue constants
@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"
You can’t perform that action at this time.