Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Xamarin Photon Led Control file for the particle cloud
// 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