// Simple NeoPixel test. Lights just a few pixels at a time so a // 1m strip can safely be powered from Arduino 5V pin. Arduino // may nonetheless hiccup when LEDs are first connected and not // accept code. So upload code first, unplug USB, connect pixels // to GND FIRST, then +5V and digital pin 6, then re-plug USB. // A working strip will show a few pixels moving down the line, // cycling between red, green and blue. If you get no response, // might be connected to wrong end of strip (the end wires, if // any, are no indication -- look instead for the data direction // arrows printed on the strip). #include "OmNeo.h" #include #define UNO 1 #if UNO #define PIN 8 #elif D1MINI #define PIN D8 #endif #define N_LEDS 16 OmNeoGrid *g4 = NULL; //OmNeo4x4 *g4 = NULL; void setup() { g4 = new OmNeoGrid(PIN, 4, 4); Serial.begin(115200); // open the serial port at 9600 bps: } int ticks = 0; void loop() { ticks++; float ra = 123; float radius = 3.75; float fx = radius * sin(ticks / ra) + 1.5; float fy = radius * sin(ticks / (ra + 1.7755)) + 1.5; float fr = cos(ticks / 200.1) * 120 + 128; float fg = sin(ticks / 205.39484) * 120 + 128; float fb = cos(ticks / 211.1992) * 120 + 128; // fr *= .1; // fg *= .1; // fb *= .1; g4->clear(); // g4->setPixelXy(1,1,0x000010); g4->drawGradientDisk(fx, fy, 3.6, g4->color(fr, fg, fb)); g4->drawRect(2.5, 2.5, 3.5, 3.5, 0x000800); g4->drawGradientDisk(1.5 ,1.5, 2.2 ,0x090000); // g4->setPixelXy(1, 0, g4->color(100,0,0)); // g4->setPixelXy(0, 2, g4->color(100,0,50)); // g4->setPixelXy(2, 1, g4->color(22,ticks & 200,10)); g4->show(); delay(3); return; }