// 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>
#ifdef __AVR__
#include <avr/power.h>
#endif
// On a Trinket or Gemma we suggest changing this to 1
#define PIN 10
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS 32
// When we setup 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 strip = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
uint32_t merah = strip.Color(255, 0, 0);
uint32_t kuning = strip.Color(255, 255, 0);
uint32_t hijau = strip.Color(10, 200, 10);
void setup() {
// put your setup code here, to run once:
strip.begin();
Serial.begin(9600);
// This is for Trinket 5V 16MHz, you can remove these three lines if you are not using a Trinket
#if defined (__AVR_ATtiny85__)
if (F_CPU == 16000000) clock_prescale_set(clock_div_1);
#endif
// End of trinket special code
strip.begin(); // This initializes the NeoPixel library.
}
static void animasi1() {
for (uint16_t r1=0; r1 < strip.numPixels()/2; r1++){
Serial.print(r1);Serial.print("; ");
strip.setPixelColor(r1, merah);
strip.setPixelColor(r1-1, 0);
strip.show();
delay(100);
if (r1 == strip.numPixels()/2-1){
strip.setPixelColor(r1, 0); // Hapus 1 led yg menyala terakhir
}
}
}
static void animasi1() {
for (uint16_t r1=0; r1 < strip.numPixels()/2; r1++){
Serial.print(r1);Serial.print("; ");
strip.setPixelColor(r1, kuning);
strip.setPixelColor(r1-1, 0);
strip.show();
delay(100);
if (r1 == strip.numPixels()/2-1){
strip.setPixelColor(r1, 0); // Hapus 1 led yg menyala terakhir
}
}
}
static void animasi2() {
for (uint16_t r2=16; r2 < strip.numPixels()/2; r2++){
Serial.print(r2);Serial.print("; ");
strip.setPixelColor(r2, merah);
strip.setPixelColor(r2-1, 16);
strip.show();
delay(100);
if (r2 == strip.numPixels()/2-1){
strip.setPixelColor(r2, 16); // Hapus 1 led yg menyala terakhir
}
}
}
void loop() {
animasi1();
animasi2();
/*
animasi3();
*/
}