This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import bluetooth | |
import time | |
import requests | |
from requests.exceptions import ConnectionError | |
payload ='' | |
while True: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 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 | |
* | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MQTT Setup | |
var mqtt = require('mqtt'); | |
console.log("Connecting to MQTT broker..."); | |
var mqtt = require('mqtt'); | |
var options = { | |
port: 1883, | |
host: '192.168.1.99', | |
clientId: 'MakeUseOf Wifi Light' | |
}; | |
var client = mqtt.connect(options); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 + |