// NeoPixel Ring simple sketch (c) 2013 Shae Erisson
// Released under the GPLv3 license to match the rest of the
// Adafruit NeoPixel library
#include <Adafruit_NeoPixel.h>
// Which pin on the Arduino is connected to the NeoPixels?
#define PIN 6 // On Trinket or Gemma, suggest changing this to 1
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 24 // Popular NeoPixel ring size
// When setting up the NeoPixel library, we tell it how many pixels,
// and which pin to use to send signals. Note that for older NeoPixel
// strips you might need to change the third parameter -- see the
// strandtest example for more information on possible values.
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
void setup()
{
pinMode(13, OUTPUT);
Serial.begin(115200); //BAUD REATE
while (!Serial);
Serial.println("Input 9 to Turn LED Off");
Serial.println("Input 1 to Turn LED Red");
Serial.println("Input 2 to Turn LED Green");
Serial.println("Input 3 to Turn LED Blue");
Serial.println("Input 4 to Turn LED Yellow (red-green)");
Serial.println("Input 5 to Turn LED Cyan (green-blue)");
Serial.println("Input 6 to Turn LED Magenta (blue-red)");
Serial.println("Input 8 to Turn LED White");
pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
}
void loop()
{
if (Serial.available())
{
int state = Serial.parseInt();
if (state == 9)
{
digitalWrite(13, LOW);
pixels.clear(); // Set all pixel colors to 'off'
pixels.show(); // This sends the updated pixel color to the hardware.
Serial.println("ok9"); //Command completed LED turned Off
}
if (state == 1)
{
digitalWrite(13, HIGH);
for(int i=0;i<NUMPIXELS;i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, pixels.Color(255,0,0));
pixels.show(); // This sends the updated pixel color to the hardware.
Serial.println("ok1"); //Command completed LED turned Red
}
}
if (state == 2)
{
digitalWrite(13, HIGH);
for(int i=0;i<NUMPIXELS;i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, pixels.Color(0,255,0));
pixels.show(); // This sends the updated pixel color to the hardware.
Serial.println("ok2"); //Command completed LED turned Green
}
}
if (state == 3)
{
digitalWrite(13, HIGH);
for(int i=0;i<NUMPIXELS;i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, pixels.Color(0,0,255));
pixels.show(); // This sends the updated pixel color to the hardware.
Serial.println("ok3"); //Command completed LED turned Blue
}
}
if (state == 4)
{
digitalWrite(13, HIGH);
for(int i=0;i<NUMPIXELS;i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, pixels.Color(255,255,0));
pixels.show(); // This sends the updated pixel color to the hardware.
Serial.println("ok4"); //Command completed LED turned Yellow (red-green)
}
}
if (state == 5)
{
digitalWrite(13, HIGH);
for(int i=0;i<NUMPIXELS;i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, pixels.Color(0,255,255));
pixels.show(); // This sends the updated pixel color to the hardware.
Serial.println("ok5"); //Command completed LED turned Cyan (green-blue)
}
}
if (state == 6)
{
digitalWrite(13, HIGH);
for(int i=0;i<NUMPIXELS;i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, pixels.Color(255,0,255));
pixels.show(); // This sends the updated pixel color to the hardware.
Serial.println("ok6"); //Command completed LED turned Magenta (blue-red)
}
}
if (state == 8)
{
digitalWrite(13, HIGH);
for(int i=0;i<NUMPIXELS;i++){
// pixels.Color takes RGB values, from 0,0,0 up to 255,255,255
pixels.setPixelColor(i, pixels.Color(255,255,255));
pixels.show(); // This sends the updated pixel color to the hardware.
Serial.println("ok8"); //Command completed LED turned White (red-green-blue)
}
}
}
}