Page last edited April 25, 2013
Text editor powered by tinymce.
Page last edited April 25, 2013
Text editor powered by tinymce.
Page last edited April 25, 2013
Text editor powered by tinymce.
D6 is the data bus for the NeoPixel, VBATT and GND also connect to + and - on the pixel. A snap is used as a switch-- one half is connected to GND and stitched to the body of the fish, and the other to TX (aka D1, any digital pin will work), and sewn to the back of the fin so you can snap and unsnap it at will. You can print out the fish pattern on transfer paper or just use it as a reference.
You an adapt this project for Gemma by changing the button pin to be Digital #0 or #2 and the NeoPixels on Digital #1 - the code will also need adjustments for the new pin connections
Page last edited April 25, 2013
Text editor powered by tinymce.
Page last edited April 25, 2013
Text editor powered by tinymce.
#include <Adafruit_NeoPixel.h> // Parameter 1 = number of pixels in strip // Parameter 2 = pin number (most are valid) // Parameter 3 = pixel type flags, add together as needed: // NEO_RGB Pixels are wired for RGB bitstream // NEO_GRB Pixels are wired for GRB bitstream // NEO_KHZ400 400 KHz bitstream (e.g. FLORA pixels) // NEO_KHZ800 800 KHz bitstream (e.g. High Density LED strip) Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, 6, NEO_GRB + NEO_KHZ800); const int buttonPin = 1; // the fin snap is connected to FLORA TX, the other half of the snap is conntected to GND int buttonState = 0; // variable for reading the snap status void setup() { strip.begin(); strip.show(); // Initialize all pixels to 'off' // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); digitalWrite(buttonPin, HIGH); } void loop() { // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); // check if the pushbutton is pressed. // if it is, the buttonState is HIGH: if (buttonState == LOW) { // turn LED on: strip.setPixelColor(0, strip.Color(200, 211, 254)); // color when snap is connected strip.show(); } else { // change LED color strip.setPixelColor(0, strip.Color(250, 0, 0)); // color when snap is disconnected strip.show(); } delay(50); }
#include <Adafruit_NeoPixel.h> // Parameter 1 = number of pixels in strip // Parameter 2 = pin number (most are valid) // Parameter 3 = pixel type flags, add together as needed: // NEO_RGB Pixels are wired for RGB bitstream // NEO_GRB Pixels are wired for GRB bitstream // NEO_KHZ400 400 KHz bitstream (e.g. FLORA pixels) // NEO_KHZ800 800 KHz bitstream (e.g. High Density LED strip) Adafruit_NeoPixel strip = Adafruit_NeoPixel(1, 6, NEO_GRB + NEO_KHZ800); const int buttonPin = 1; // the fin snap is connected to FLORA TX, the other half of the snap is conntected to GND int buttonState = 0; // variable for reading the snap status void setup() { strip.begin(); strip.show(); // Initialize all pixels to 'off' // initialize the pushbutton pin as an input: pinMode(buttonPin, INPUT); digitalWrite(buttonPin, HIGH); } void loop() { // read the state of the pushbutton value: buttonState = digitalRead(buttonPin); // check if the pushbutton is pressed. // if it is, the buttonState is HIGH: if (buttonState == LOW) { // turn LED on: strip.setPixelColor(0, strip.Color(200, 211, 254)); // color when snap is connected strip.show(); } else { // change LED color strip.setPixelColor(0, strip.Color(250, 0, 0)); // color when snap is disconnected strip.show(); } delay(50); }
You an adapt this project for Gemma by changing the button pin to be Digital #0 or #2 and the NeoPixels on Digital #1 - the code will also need adjustments for the new pin connections
Page last edited April 25, 2013
Text editor powered by tinymce.
Page last edited April 25, 2013
Text editor powered by tinymce.
Page last edited April 25, 2013
Text editor powered by tinymce.
Page last edited April 25, 2013
Text editor powered by tinymce.