Created
December 25, 2014 20:08
-
-
Save jasoncoon/42dc985a6dbf166dd203 to your computer and use it in GitHub Desktop.
BlinkyTile Simple Cycle Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The simplest possible way to talk to a BlinkyTape | |
import processing.serial.*; | |
Serial s; | |
void setup() { | |
// Connect to the first serial port we can find | |
// We assume there is a BlinkyTape there | |
s = new Serial(this, "COM6", 115200); | |
} | |
int index = 0; | |
void draw() { | |
for (int i = 0; i < 12; i++) { | |
// Make up a pretty color based on the current phase | |
color c = color(0, 0, 0); | |
if (i == index) | |
c = color(254, 0, 0); | |
// Send the color for the current LED to the strip, | |
// being careful not to send 255 (because that would | |
// cause the strip to display the pixels | |
s.write((byte)min(254, red(c))); | |
s.write((byte)min(254, green(c))); | |
s.write((byte)min(254, blue(c))); | |
} | |
// Send a 0xFF byte to the strip, to tell it to display the pixels | |
s.write((byte)255); | |
delay(8); | |
index++; | |
if (index >= 12) | |
index = 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a simple Processing sketch to control a BlinkyTile via Processing. Based on (and slightly modified from) "The Simplest BlinkyTape Program" at http://blinkinlabs.com/blinkytape/processing