Skip to content

Instantly share code, notes, and snippets.

View bassdread's full-sized avatar

bassdread

  • UK
View GitHub Profile
@bassdread
bassdread / gist:8088230
Last active January 1, 2016 03:49
update blinkstick and led strip code, still rough round the edges.
from blinkstick import blinkstick
import requests
import serial
import webcolors
import time
import json
# url to fetch from
cheer_lights_url = "http://api.thingspeak.com/channels/1417/field/1/last.json"
serial_port = '/dev/tty.usbmodem1421'
@bassdread
bassdread / gist:8088217
Created December 22, 2013 20:46
arduino code
// color swirl! connect an RGB LED to the PWM pins as indicated
// in the #defines
// public domain, enjoy!
#define REDPIN 5
#define GREENPIN 6
#define BLUEPIN 3
#define FADESPEED 5 // make this higher to slow down
import platform
import requests
class Choir:
def __init__(self, agentConfig, checksLogger, rawConfig):
self.agentConfig = agentConfig
self.checksLogger = checksLogger
self.rawConfig = rawConfig
self.version = platform.python_version_tuple()
#!/usr/bin/env python
#
# Copyright 2007 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
@bassdread
bassdread / gist:8032083
Last active December 31, 2015 19:09
Code for make blink sticks talk to cheer lights. More info at http://www.cheerlights.com/subscribe-to-cheerlights-feed and blinkstick.com
#!/usr/bin/python
"""
Download this script and run it as
```
python thenameofthefile.py
```
or
var BMP085 = require('bmp085'),
barometer = new BMP085(
{
'mode' : 0,
'address': 0x77,
'device': '/dev/i2c-0'
}
);
barometer.read(function (data) {
console.log("Temperature:", data.temperature);
@bassdread
bassdread / gist:7589445
Created November 21, 2013 20:54
npm install i2c
$ npm install i2c
npm http GET https://registry.npmjs.org/i2c
npm http 304 https://registry.npmjs.org/i2c
npm http GET https://registry.npmjs.org/bindings
npm http GET https://registry.npmjs.org/underscore/1.2.4
npm http GET https://registry.npmjs.org/coffee-script/1.3.3
npm http GET https://registry.npmjs.org/repl/0.1.3
npm http 304 https://registry.npmjs.org/coffee-script/1.3.3
npm http 304 https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/underscore/1.2.4
execve("node-v0.11.7-linux-arm-pi/bin/node", ["node-v0.11.7-linux-arm-pi/bin/no"...], [/* 17 vars */]) = -1 ENOENT (No such file or directory)
dup(2) = 3
fcntl64(3, F_GETFL) = 0x20002 (flags O_RDWR|O_LARGEFILE)
fstat64(3, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
mmap2(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0xb6f07000
_llseek(3, 0, 0xbead3308, SEEK_CUR) = -1 ESPIPE (Illegal seek)
write(3, "strace: exec: No such file or di"..., 40strace: exec: No such file or directory
) = 40
close(3) = 0
munmap(0xb6f07000, 4096) = 0
pi@neptr ~ $ uname -a
Linux neptr 3.6.11+ #538 PREEMPT Fri Aug 30 20:42:08 BST 2013 armv6l GNU/Linux
pi@neptr ~ $ curl -O http://nodejs.org/dist/v0.11.7/node-v0.11.7-linux-arm-pi.tar.gz
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 4843k 100 4843k 0 0 816k 0 0:00:05 0:00:05 --:--:-- 939k
pi@neptr ~ $ tar zxf node-v0.11.7-linux-arm-pi.tar.gz
pi@neptr ~ $ node-v0.11.7-linux-arm-pi/bin/node -e 'console.log("hello")'
-su: node-v0.11.7-linux-arm-pi/bin/node: No such file or directory
pi@neptr ~ $ ldd node-v0.11.7-linux-arm-pi/bin/node
http://bildr.org/2011/07/ds18b20-arduino/ - Temperature sensor
http://bildr.org/2012/11/photoresistor-arduino/ - Light sensor
http://www.ebay.co.uk/itm/Soil-Hygrometer-Detection-Buzzer-Alarm-Module-Moisture-Sensor-Cable-For-Arduino-/390643155171?pt=UK_BOI_Industrial_Automation_Control_ET&hash=item5af42580e3 - In analog mode just read straight from the analog input
www.maplin.co.uk/amazing-h2o-pump-228295 - Water pump
http://www.ebay.co.uk/itm/360626244581?ssPageName=STRK:MEWNX:IT&_trksid=p3984.m1497.l2649 - Irrigation system
http://www.ebay.co.uk/itm/Nano-V3-0-ATmega328P-Arduino-Compatible-/171078373098?pt=LH_DefaultDomain_0&hash=item27d510ceea - Nano