Skip to content

Instantly share code, notes, and snippets.

@hhayley
Created May 7, 2017 02:39
Show Gist options
  • Save hhayley/7c62d8c1e3e260793b533a62efca66e4 to your computer and use it in GitHub Desktop.
Save hhayley/7c62d8c1e3e260793b533a62efca66e4 to your computer and use it in GitHub Desktop.
PIXIE+MKR1000 without SoftwareSerial
/*
MKR1000 + PIXIE 3w leds
without sofrwareSerial
UNO -> 1(TX)
MKR1000 -> 14(TX)
*/
//#include "SoftwareSerial.h"
#include "Adafruit_Pixie.h"
#define NUMPIXELS 2 // Number of Pixies in the strip
//#define PIXIEPIN 6 // Pin number for SoftwareSerial output
//SoftwareSerial pixieSerial(-1, PIXIEPIN);
//Adafruit_Pixie strip = Adafruit_Pixie(NUMPIXELS, &pixieSerial);
// Alternately, can use a hardware serial port for output, e.g.:
Adafruit_Pixie strip = Adafruit_Pixie(NUMPIXELS, &Serial1); // MKR1000 ->14(TX)
// Adafruit_Pixie strip = Adafruit_Pixie(NUMPIXELS, &Serial); // UNO -> 1(TX)
void setup() {
// Serial.begin(9600);
// Serial.println("Ready to Pixie!");
// pixieSerial.begin(115200); // Pixie REQUIRES this baud rate
Serial1.begin(115200); // <- Alt. if using hardware serial port
//Serial.begin(115200);
// Adjust as necessary to avoid blinding
}
void loop() {
// Serial.println("Rainbow!");
rainbowCycle(10);
}
// Slightly different, this makes the rainbow equally distributed throughout
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
for (j = 0; j < 256 * 5; j++) { // 5 cycles of all colors on wheel
for (i = 0; i < NUMPIXELS; i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
}
// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
if (WheelPos < 85) {
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
} else if (WheelPos < 170) {
WheelPos -= 85;
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment