Skip to content

Instantly share code, notes, and snippets.

View dansteingart's full-sized avatar

Dan Steingart dansteingart

View GitHub Profile
@dansteingart
dansteingart / Figrelli-L12_R_I.ino
Last active March 9, 2016 14:23
Arduino Code to Control an Figrelli L-12 Series (R or I Type) Linear Actuator via PWM/Serial Command
int incomingByte = 0; // for incoming serial data
int pin = 7; //White Cable Goes Here, Red to 5V, Black to GND
void setup() {
//Serial
pinMode(pin,OUTPUT);
Serial.begin(9600); // set up Serial library at 9600 bps
}
@dansteingart
dansteingart / arb_sort.py
Created January 15, 2014 04:37
Sorting against an arbitrary standard
#Driven By Trello Card Sorting
#We want to preserve this order
color_list = ['green','yellow','orange','red','purple','blue']
dd = [
{'color':'yellow','name':'Jet'},
{'color':'blue','name':'Spike'},
{'color':'green','name':'Faye'},
{'color':'purple','name':'Ed'},
@dansteingart
dansteingart / 0_reuse_code.js
Created January 8, 2014 15:30
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
/**
* ReadSHT1xValues
*
* Read temperature and humidity values from an SHT1x-series (SHT10,
* SHT11, SHT15) sensor.
*
* Copyright 2009 Jonathan Oxer <[email protected]>
* www.practicalarduino.com
*/
@dansteingart
dansteingart / arduino_listener.ino
Created October 2, 2013 16:13
MAE 221/224 Lab Stuff
void setup(){
Serial.begin(57600);
millis();
//analogReference(DEFAULT);
}
float vals[6];
void RMSAveraged(int time){
@dansteingart
dansteingart / keithleytest.py
Created September 12, 2013 20:52
Keithley and Python
import serial
from glob import glob
port = glob("/dev/tty.u*")[0]
ser = serial.Serial(port,57600)
ser.open()
ser.timeout = .5
def write(string):
import serial
from glob import glob
from time import sleep
port = glob("/dev/tty.usb*")[0]
ard = serial.Serial(port,57600)
print "waiting to start"
for i in range(3,0,-1):
print i,
sleep(1)
# code to set set current here
for i in range(120):
#code to get data here
time.sleep(.5)
@dansteingart
dansteingart / Spawner.js
Created November 1, 2012 01:09
Keeping Tabs On Multiple Spawned Processes in NodeJS
//First make placeholders for results as globals
results = {}
processes = {}
//Now Spawn Processes within code you need, where index is an identifier
spawn_list[index] = spawn(/*file here*/)
processes[index] = spawn_list[index].pid
results[processes[index]] = {}
results[processes[index]]['index'] = index //funny looking but important
results[processes[index]]['stdout'] = ""
@dansteingart
dansteingart / outout.js
Created March 9, 2012 03:00
Node Script for MongoExport
var exec = require('child_process').exec;
var child;
//Put path to mongoexport here
mel = "/Users/ardustat/Downloads/mongodb-osx-x86_64-2.0.2/bin/mongoexport"
function mongoexport(collection)
{
out_string = mel + " -csv -o "+collection+".csv -d ardustat -c "+collection+" -f time,cell_potential,working_potential,current"
child = exec(out_string, function (error, stdout, stderr)