Skip to content

Instantly share code, notes, and snippets.

View urish's full-sized avatar

Uri Shaked urish

View GitHub Profile
@urish
urish / wireless-power.ino
Created January 2, 2016 16:11
Simple Arduino Wireless Power
int led = 13;
void setup() {
pinMode(led, OUTPUT);
}
void loop() {
digitalWrite(led, HIGH);
delayMicroseconds(1);
digitalWrite(led, LOW);
@urish
urish / motorcoil.ino
Created January 6, 2016 10:06
motorcoil
const int phase1pin = 2;
const int phase2pin = 4;
const int phase3pin = 3;
float holdTime = 50000; // microsecs
const unsigned long minHoldTime = 10000;
unsigned long p1start,
p1end,
p2start,
p2end,
@urish
urish / googleForms.js
Created January 21, 2016 12:28
Angular service to post reponses to a google form
function googleFormsService ($q, $rootScope, jQuery) {
angular.extend(this, {
/**
* Sends a response using Google Forms AJAX API (informal)
* @param {String} formKey The key of the form, e.g. 15QFO2VE44-9gAwcJeTPPWvxAX7v_1Ye9qmjdX2VzLBw
* @param {Object} values A list of key-value pairs to send as the form data, e.g. {'entry.6939333': 'John', 'entry.7399349': Due}
* @returns {*} Promise that will be resolved after the form request has been submitted
*/
sendResponse(formKey, values) {
var deferred = $q.defer();
@urish
urish / neopixel.ino
Last active November 6, 2021 20:16
Simple NeoPixel Animation for Arduino on WeMos D1 Mini, License: MIT
#include <Adafruit_NeoPixel.h>
#define NUM_PIXELS 24
Adafruit_NeoPixel pixels(NUM_PIXELS, D2, NEO_GRB | NEO_KHZ800);
void setup() {
pixels.begin();
}
@urish
urish / install.sh
Created July 17, 2016 08:45
Installing airfoilspeakers on nextthingco CHIP
#! /bin/sh
wget http://rogueamoeba.com/airfoil/download/AirfoilSpeakersLinux.all.deb
wget http://rogueamoeba.com/airfoil/download/AirfoilSpeakersRaspberryPi.tgz
sudo dpkg -i AirfoilSpeakersLinux.all.deb
sudo apt-get install -f
tar zxf AirfoilSpeakersRaspberryPi.tgz
sudo cp -p ./airfoilspeakers/lib/*ARM.so /usr/lib/airfoilspeakers
airfoilspeakers
@urish
urish / lightsnake.ino
Last active January 7, 2017 15:06
APA102 Light snake (Arduino)
#include <FastGPIO.h>
#define APA102_USE_FAST_GPIO
#include <APA102.h>
APA102<11, 12> ledStrip;
const uint16_t ledCount = 144;
rgb_color pixels[ledCount];
void setup() {
@urish
urish / ng-beacon-bulb.js
Last active March 25, 2017 00:41
ng-beacon controlling a Magic Blue smart bulb
function startLoop(char) {
console.log('Connected !');
setInterval(function() {
var t = ngbeacon.temperature();
console.log(t);
var r = t > 22 ? 0xff : 0,
g = 0,
b = t > 22 ? 0 : 0xff;
char.writeValue(new Uint8Array([0x56, r, g, b, 0, 0xf0, 0xaa]));
}, 1000);
function updateValues() {
var temperature = new Uint16Array([ngbeacon.humidity() * 100]);
var humidity = new Uint16Array([ngbeacon.humidity() * 100]);
NRF.updateServices({
0x181A: {
0x2A6E: { value: temperature.buffer, notify: true },
0x2A6F: { value: humidity.buffer, notify: true }
}
});
}
for (let i = 0; i < 0x80; i++) {
try { I2C1.readFrom(i, 1); console.log(i); } catch (e) {}
}
@urish
urish / ng-beacon-bulb-rssi.js
Created April 24, 2017 11:01
NG Beacon controlling a Magic Blue bulb based on distance
var bulbDevice = null;
var bulbChar = null;
function setColor(r, g, b) {
try {
bulbChar.writeValue(new Uint8Array([0x56, r, g, b, 0, 0xf0, 0xaa]));
} catch (e) {
}
}