Skip to content

Instantly share code, notes, and snippets.

View jamesabruce's full-sized avatar

James Bruce jamesabruce

  • Cornwall, UK
View GitHub Profile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# All Vagrant configuration is done here. The most common configuration
# options are documented and commented below. For a complete reference,
# please see the online documentation at vagrantup.com.
Jamess-iMac:Applications jamie$ ls -R
GitHub.app Vagrantfile Windows 7 Applications.app
./.vagrant/machines:
default
./.vagrant/machines/default:
virtualbox
./.vagrant/machines/default/virtualbox:
/*
* 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
*
*/
/*
RESTduino
A REST-style interface to the Arduino via the
Wiznet Ethernet shield.
Based on David A. Mellis's "Web Server" ethernet
shield example sketch.
Circuit:
// Slightly modified Adalight protocol implementation that uses FastLED
// library (http://fastled.io) for driving WS2811/WS2812 led stripe
// Was tested only with Prismatik software from Lightpack project
#include "FastLED.h"
#define NUM_LEDS 114 // Max LED count
#define LED_PIN 6 // arduino output pin
#define GROUND_PIN 10
#define BRIGHTNESS 255 // maximum brightness
/*
Qyuick and dirty IR signal over i2c rebroadcast for
Lighting Cloud Mood Lamp By James Bruce
View the full tutorial and build guide at http://www.makeuseof.com/
Used to get around the limitations of having two libraries that both require exact timings to work right!
*/
#include <Wire.h>
#include <IRremote.h>
/*
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 / neomatrix_pixel_display.ino
Created January 22, 2015 17:55
Sample code for working with the giant LED screen described at MakeUseOf.com, using Adafruit Neomatrix and GFX libraries
#include <Adafruit_GFX.h>
#include <Adafruit_NeoMatrix.h>
#include <Adafruit_NeoPixel.h>
#define XSIZE 15
#define YSIZE 14
#define PIN 6
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(XSIZE, YSIZE, PIN,
NEO_MATRIX_BOTTOM + NEO_MATRIX_LEFT +
@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 / Control Philips Hue from Arduino Ethernet Shield
Created April 5, 2015 20:43
Example of using an Arduino with Ethernet shield to control Philips Hue, with PIR motion sensor on i/o pin 2.
/*
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