Last active
September 12, 2016 17:39
-
-
Save MobileRez/5d2f21028735221f8592 to your computer and use it in GitHub Desktop.
Xamarin Photon Led Control file for the particle cloud
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
// This #include statement was automatically added by the Particle IDE. | |
#include "neopixel/neopixel.h" | |
SYSTEM_MODE(AUTOMATIC); | |
// IMPORTANT: Set pixel COUNT, PIN and TYPE | |
#define PIXEL_PIN D2 | |
#define PIXEL_COUNT 288 | |
#define PIXEL_TYPE WS2812B | |
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE); | |
int ledState = 0; | |
void stripSetPixelColor(unsigned char red, unsigned char green, unsigned char blue) | |
{ | |
uint16_t i; | |
for (int i = 0 ; i < strip.numPixels() ; i += 1 ) | |
{ | |
strip.setPixelColor(i, strip.Color(red,green,blue)); | |
} | |
strip.show(); | |
} | |
void redStrip(uint8_t wait) | |
{ | |
stripSetPixelColor(255, 0, 0); | |
delay(wait); | |
} | |
void orangeStrip(uint8_t wait) | |
{ | |
stripSetPixelColor(255,58,0); | |
delay(wait); | |
} | |
void yellowStrip(uint8_t wait) | |
{ | |
stripSetPixelColor(255,255,0); | |
delay(wait); | |
} | |
void greenStrip(uint8_t wait) | |
{ | |
stripSetPixelColor(0,255,0); | |
delay(wait); | |
} | |
void cyanStrip(uint8_t wait) | |
{ | |
stripSetPixelColor(0,255,255); | |
delay(wait); | |
} | |
void blueStrip(uint8_t wait) | |
{ | |
stripSetPixelColor(0,0,255); | |
delay(wait); | |
} | |
void purpleStrip(uint8_t wait) | |
{ | |
stripSetPixelColor(255,0,255); | |
delay(wait); | |
} | |
void magentaStrip(uint8_t wait) | |
{ | |
stripSetPixelColor(155,48,255); | |
delay(wait); | |
} | |
void pinkStrip(uint8_t wait) | |
{ | |
stripSetPixelColor(255,182,203); | |
delay(wait); | |
} | |
void whiteStrip(uint8_t wait) | |
{ | |
stripSetPixelColor(255,255,255); | |
delay(wait); | |
} | |
void off(uint8_t wait) | |
{ | |
stripSetPixelColor(0,0,0); | |
delay(wait); | |
} | |
int ledColor(String command) | |
{ | |
if(command == "white") | |
{ | |
whiteStrip(20); | |
return 1; | |
} | |
else if(command == "pink") | |
{ | |
pinkStrip(20); | |
return 1; | |
} | |
else if(command == "red") | |
{ | |
redStrip(20); | |
return 1; | |
} | |
else if(command == "orange") | |
{ | |
orangeStrip(20); | |
return 1; | |
} | |
else if(command == "yellow") | |
{ | |
yellowStrip(20); | |
return 1; | |
} | |
else if(command == "green") | |
{ | |
greenStrip(20); | |
return 1; | |
} | |
else if(command == "cyan") | |
{ | |
cyanStrip(20); | |
return 1; | |
} | |
else if(command == "blue") | |
{ | |
blueStrip(20); | |
return 1; | |
} | |
else if(command == "purple") | |
{ | |
purpleStrip(20); | |
return 1; | |
} | |
else if(command == "magenta") | |
{ | |
magentaStrip(20); | |
return 1; | |
} | |
else if(command == "off") | |
{ | |
off(20); | |
return 1; | |
} | |
else return -1; | |
} | |
void setup() { | |
strip.begin(); | |
strip.show(); // Initialize all pixels to 'off' | |
/* Set up particle function to recieve code for */ | |
Particle.function("ledcolor", ledColor); | |
} | |
void loop() { | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment