Skip to content

Instantly share code, notes, and snippets.

View jimwhitfield's full-sized avatar

Jim Whitfield jimwhitfield

  • Silicon Valley, California
View GitHub Profile
@jimwhitfield
jimwhitfield / rgb_cycle
Created October 19, 2014 00:10
Simple little arduino sketch that cycles through a bunch of color combinations on an arduino driving an RGB LED.
const int RED_PIN = 9;
const int GREEN_PIN = 10;
const int BLUE_PIN = 11;
const int MAX_VAL=255;
void setup() {
// initialize digital pins as output:
for (int i = PIN_BASE; i <= PIN_BASE+PIN_CT; i++) {
@jimwhitfield
jimwhitfield / led_matrix_leap
Last active August 29, 2015 14:07
led_matrix_leap
// !!!
// Scroll down past where the alphabet is defined in order to set what to say
// !!!
#define CHAR_WIDTH 5 // each character is 5 columns wide
#define SP {0, 0, 0, 0, 0} //Space
#define DOT {0, 0, 1, 0, 0} //Space
#define EX {0, 125, 0, 0, 0} //Exclamation !
#define EX2 {0, 125, 0, 125, 0} //Exclamation !!
#define A {31, 36, 68, 36, 31}
#define B {127, 73, 73, 73, 54,}
@jimwhitfield
jimwhitfield / random_leds
Created October 20, 2014 05:21
random_leds - randomly turn LEDs on and off
int PIN_BASE=4; // lowest pin to use.
int PIN_CT=6; // number of LEDs attached
int delayBase=35; // a heartbeat, of sorts. in milliseconds.
void setup() {
// initialize digital pins (base) to (base+count) as output:
for (int i = PIN_BASE; i <= PIN_BASE+PIN_CT; i++) {
@jimwhitfield
jimwhitfield / led_toy
Last active August 29, 2015 14:07
arduino code for special effects for LEDs attached to an arduino. "arduino due" necessary when using PWM on lots of output pins
int PIN_BASE=2;
int PINS_TO_USE=10;
#define STANDARD 0x0
#define INSTANT 0x1 // not &0x1 ? then standard speed
@jimwhitfield
jimwhitfield / strand-bright.
Created June 8, 2015 01:31
an enhancement to the stock neoPixel Ring script (pastels, countdown, dual rainbow)
#include <Adafruit_NeoPixel.h>
#include <avr/power.h>
#define PIN 6
// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// Gray text with two slashes are just helpful comments, you don’t need to type them. :)
/******* -----=====!! EASY STUFF TO MESS WITH !!=====------ ******/
// What analog pin should we use to read the value from the potentiometer?
int analogPin = 2; // Yep, you heard right: The coolest of the Analog pins...
// What pins are the LEDs connected to?
int redPin = 9;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jimwhitfield
jimwhitfield / led_matrix_htf.ino
Created August 21, 2015 22:09
Scrolling message saying WELCOME TO HACK THE FUTURE
// !!!
// Scroll down past where the alphabet is defined in order to set what to say
// !!!
#define CHAR_WIDTH 5 // each character is 5 columns wide
#define SP {0, 0, 0, 0, 0} //Space
#define DOT {0, 0, 1, 0, 0} //Space
#define EX {0, 125, 0, 0, 0} //Exclamation !
#define EX2 {0, 125, 0, 125, 0} //Exclamation !!
#define A {31, 36, 68, 36, 31}
#define B {127, 73, 73, 73, 54}
@jimwhitfield
jimwhitfield / OPS241 NodeRed Flow
Created May 7, 2017 04:29
A NodeRed flow that reads from the OPS241 and plays a wav file if over the speed threshold
[
{
"id": "8eb36c95.abf588",
"type": "exec",
"z": "bb84ba45.9732b8",
"command": "/usr/bin/aplay",
"addpay": false,
"append": "/home/pi/SlowDown1s.wav",
"useSpawn": "",
"timer": "",
@jimwhitfield
jimwhitfield / PC-OPS241 NodeRed.json
Last active May 8, 2017 18:22
A Node Red flow for PC which reads from COM3 and plays the audio file (as coded) in the browser
[
{
"id": "90b76976.49ff38",
"type": "tab",
"label": "Flow 1"
},
{
"id": "52bcfbfe.e89d74",
"type": "switch",
"z": "90b76976.49ff38",