Skip to content

Instantly share code, notes, and snippets.

View shfitz's full-sized avatar
📠
📠📠📠📠

Scott Fitzgerald shfitz

📠
📠📠📠📠
View GitHub Profile
### Keybase proof
I hereby claim:
* I am shfitz on github.
* I am shfitz (https://keybase.io/shfitz) on keybase.
* I have a public key whose fingerprint is 0D13 514B 3961 212A 9869 C66F 861B A4D9 AE02 D6F6
To claim this, I am signing this object:
@shfitz
shfitz / sparkle.ino
Created June 14, 2017 21:04
BlinkyTape sparkle
/*
Creates a randomly sparkling effect on an arbitrary number of
LEDs using the WS2812 driver.
*/
#include <Adafruit_NeoPixel.h> // include the neopixel library
// most people use FastLED for the blinkytape, but the Adafruit
// library is more my speed
#define PIN 13 // we're using the blinkytape, data is pin 13
@shfitz
shfitz / sendValueSwitch.ino
Last active March 28, 2020 19:37
Example code to send a serial byte from an Arduino microcontroller
// demonstrates sending a value from an arduino to p5js
// which inicates if a switch is pressed or not
// a switch is wired to pin 2 with a 10K pulldown resistor in parallel
const int switchPin = 2; // pin the switch is connected to
int switchVal = 0; // variable to hold the value from the switch
void setup() {
// set pin as input
pinMode(switchPin, INPUT);
// demonstrates sending a value from an arduino to p5js
// which inicates the position of a potentiometer connected to pin A0
const int potPin = A0; // pin the pot is connected to
int potVal = 0; // variable to hold the value from the sensor
void setup() {
// initialize the serial communication:
const int ledPin = 3; // the pin that the LED is attached to
void setup() {
// initialize the serial communication:
Serial.begin(9600);
// initialize the ledPin as an output:
pinMode(ledPin, OUTPUT);
}
void loop() {
int firstSensor = 0; // first analog sensor
int secondSensor = 0; // second analog sensor
int thirdSensor = 0; // digital sensor
int inByte = 0; // incoming serial byte
void setup() {
// start serial port at 9600 bps and wait for port to open:
Serial.begin(9600);
while(!Serial){
;;
// include the neopixel library
#include <Adafruit_NeoPixel.h>
int ledPin = 3; // the pin the LED data line is connected to
int numLED = 5; // number of LEDs you are controlling
// call the constructor
Adafruit_NeoPixel leds(numLED, ledPin, NEO_GRB + NEO_KHZ800);
// variables to hold colors
// include the neopixel library
#include <Adafruit_NeoPixel.h>
int ledPin = 3; // the pin the LED data line is connected to
int numLED = 5; // number of LEDs you are controlling
// call the constructor
Adafruit_NeoPixel leds(numLED, ledPin, NEO_GRB + NEO_KHZ800);
int sensorPin = A0; // pin the sensor is attached to
/*
Creates a randomly sparkling effect on an arbitrary number of
LEDs using the WS2812 driver.
*/
#include <Adafruit_NeoPixel.h> // include the neopixel library
// most people use FastLED for the blinkytape, but the Adafruit
// library is more my speed
#define PIN 3 // we're using the blinkytape, data is pin 13
// include the neopixel library
#include <Adafruit_NeoPixel.h>
int ledPin = 3; // the pin the LED data line is connected to
int numLED = 5; // number of LEDs you are controlling
// call the constructor for the neopixels
Adafruit_NeoPixel leds(numLED, ledPin, NEO_GRB + NEO_KHZ800);
int input[] = {0, 0, 0}; // an array to hold color data