Skip to content

Instantly share code, notes, and snippets.

Avatar

Ron Dagdag rondagdag

View GitHub Profile
@rondagdag
rondagdag / LittlebitsWebSocket.cs
Created November 30, 2015 20:20
Here's my code to connect Unity3d to Littlebits Cloudbit via websockets
View LittlebitsWebSocket.cs
using UnityEngine;
using System.Collections;
using System;
using System.Security.Policy;
using System.Threading;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using WebSocketSharp;
using WebSocketSharp.Net;
@rondagdag
rondagdag / MindControlledBB8Droid
Created November 30, 2015 21:12
NodeJS application
View MindControlledBB8Droid
var Cylon = require('cylon');
var Barcli = require("barcli");
var attentionGraph = new Barcli({
label: "attention Graph",
range: [0, 100],
});
var apiKey = '<Your API Key>';
var IFTTTMaker = require('iftttmaker')(apiKey);
var trigger_on = 'MindControlTrigger_On';
View DinoController.cs
using UnityEngine;
using System.Collections;
public class DinoController : MonoBehaviour {
GameObject player;
// Use this for initialization
Vector3 initialPosition;
public float speed = 0.1F;
public AnimationClip idleAnimation01 ;
@rondagdag
rondagdag / LittlebitsNode.cs
Created December 22, 2015 23:37
Unity3d script to connect to NodeJS using WebSocketSharp
View LittlebitsNode.cs
using UnityEngine;
using System.Collections;
using System;
using System.Security.Policy;
using System.Threading;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using WebSocketSharp;
using WebSocketSharp.Net;
View broadcast-littlebits-ws.js
var ws = require("nodejs-websocket")
// Scream server example: "hi" -> "HI!!!"
var server = ws.createServer(function (conn) {
console.log("New connection")
conn.on("text", function (str) {
console.log("Received "+str)
conn.sendText(str.toUpperCase()+"!!!")
})
conn.on("close", function (code, reason) {
@rondagdag
rondagdag / imu-udp.ino
Created December 30, 2015 20:42
IMU to UDP for particle photon
View imu-udp.ino
// This #include statement was automatically added by the Particle IDE.
#include "Kalman/Kalman.h"
#include "SparkFunLSM9DS1/SparkFunLSM9DS1.h"
#include "math.h"
unsigned long lastRead= micros();
char myIpAddress[24];
View UDPReceiverSaber.cs
// ------------------------------------------------------------------------------
/*
-----------------------
UDP-Receive (send to)
-----------------------
// [url]http://msdn.microsoft.com/de-de/library/bb979228.aspx#ID0E3BAC[/url]
// > receive
// 127.0.0.1 : 8051
@rondagdag
rondagdag / LittlebitsWebSocket.cs
Created January 3, 2016 02:53
Littlebits Web Socket using WebSocketSharp.Net and Newtonsoft.Json
View LittlebitsWebSocket.cs
using UnityEngine;
using System.Collections;
using System;
using System.Security.Policy;
using System.Threading;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using WebSocketSharp;
using WebSocketSharp.Net;
@rondagdag
rondagdag / PhotonWS.cs
Created February 5, 2016 21:25
Here's what I used to receive UDP Packets from Photon
View PhotonWS.cs
using UnityEngine;
using System.Collections;
using System;
using System.Security.Policy;
using System.Threading;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
using System.Net.Sockets;
@rondagdag
rondagdag / CM_RandomEyesBroadcastEventTester.cs
Created February 24, 2016 21:41
This is how I set the move type to be sent to web app in raspberry pi
View CM_RandomEyesBroadcastEventTester.cs
using UnityEngine;
using System.Collections;
using CrazyMinnow.SALSA; // Import SALSA from the CrazyMinnow namespace
/*
Script usage instructions
This class demonstrates the use of the RandomEyes 2D/3D [Broadcast Eye Events],
and the RandomEyes 3D [Broadcast Custom Shape Events], to catch