Skip to content

Instantly share code, notes, and snippets.

@corybarr
corybarr / gist:19a61104e299af402dd66a729d4fda57
Created July 9, 2018 21:02
Code to read from cheap rotary encoder
int pinA = 2; // Connected to CLK on KY-040
int pinB = 3; // Connected to DT on KY-040
int encoderPosCount = 0;
int pinALast;
int aVal;
boolean bCW;
void setup() {
pinMode (pinA,INPUT);
pinMode (pinB,INPUT);
// Red - 5V
// Black - GND
const int encoder_a = 2; // Green - pin 2 - Digital
const int encoder_b = 3; // White - pin 3 - Digital
long encoder = 0;
void setup() {
Serial.begin(9600);
pinMode(encoder_a, INPUT_PULLUP);
pinMode(encoder_b, INPUT_PULLUP);
float playerOneRot = 0.5;
float playerTwoRot = 0.5;
PVector ballPath = new PVector();
PVector ballPos, ballVel;
float padX;
float padY;
void setup() {
//use this...
for (int i = 0; i < images.length; i++) {
mainColors[i] = extractColorFromImage(images[i]);
}
//..to replace this
//mainColors[0] = extractColorFromImage(img1);
//mainColors[1] = extractColorFromImage(img2);
//mainColors[2] = extractColorFromImage(img3);
//mainColors[3] = extractColorFromImage(img4);
//mainColors[4] = extractColorFromImage(img5);
float playerOneRot = 0.5;
float playerTwoRot = 0.5;
PVector ballGo = new PVector();
PVector ballPosition, ballVelocity;
void setup() {
size(800, 800);
ballPosition = new PVector();
ballVelocity = new PVector();
//trying to get the screen to fill entirely with a column of random bars of color.
//The bars of color correspond to the dominant colors pulled from craigslist images.
PImage img1;
PImage img2;
PImage img3;
PImage img4;
PImage img5;
PImage img6;
PImage img7;
import gab.opencv.*;
import processing.video.*;
import java.awt.*;
int cameraResW = 1280;
int cameraResH = 720;
float scaleRatioW, scaleRatioH;
Capture video;
OpenCV opencv;
/**
* Getting Started with Capture.
*
* Reading and displaying an image from an attached Capture device.
*/
import processing.video.*;
Capture cam;
@corybarr
corybarr / gist:788967f1f54533ba2d26a8cd37fc423c
Created October 30, 2016 23:26
adding a bit of code to April's sketch
// It would be a maze zing if April could figure this out.
Kite k;
void setup() {
size(700, 700);
smooth();
bgGradient();
cloudMaze();
k = new Kite();
GsnapParam <- function(genome = GmapGenome(), unique_only = FALSE,
max_mismatches = NULL,
suboptimal_levels = 0L, mode = "standard",
use_snps = NULL, snpsdir = GmapSnpDirectory(genome),
npaths = if (unique_only) 1L else 100L,
quiet_if_excessive = unique_only, nofails = unique_only,
split_output = !unique_only,
novelsplicing = FALSE, splicing = NULL,
nthreads = 1L, part = NULL, batch = "2", ...) {
params <- formals(sys.function())