//https://chat.openai.com/share/614e4fef-64d8-41aa-b8bd-25a045dff8bd
// AI CREATED CODE BY ARVIND
#include <Adafruit_NeoPixel.h>
#define PIN 2
#define NUM_PIXELS 256
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUM_PIXELS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
pixels.begin();
}
void loop() {
displayRandomShape();
delay(1000); // Wait for a second between each shape display
}
void displayRandomShape() {
int shape = random(3); // 0: square, 1: rectangle, 2: circle
uint32_t color = randomColor();
switch (shape) {
case 0:
displayRandomSquare(color);
break;
case 1:
displayRandomRectangle(color);
break;
case 2:
displayRandomCircle(color);
break;
}
}
void displayRandomSquare(uint32_t color) {
int size = random(2, 16); // Random size between 2 and 15 pixels
int startX = random(16 - size);
int startY = random(16 - size);
for (int x = startX; x < startX + size; x++) {
for (int y = startY; y < startY + size; y++) {
pixels.setPixelColor(y * 16 + x, color);
}
}
pixels.show();
}
void displayRandomRectangle(uint32_t color) {
int width = random(2, 16);
int height = random(2, 16);
int startX = random(16 - width);
int startY = random(16 - height);
for (int x = startX; x < startX + width; x++) {
for (int y = startY; y < startY + height; y++) {
pixels.setPixelColor(y * 16 + x, color);
}
}
pixels.show();
}
void displayRandomCircle(uint32_t color) {
int centerX = random(16);
int centerY = random(16);
int radius = random(1, 8); // Random radius between 1 and 7 pixels
for (int x = 0; x < 16; x++) {
for (int y = 0; y < 16; y++) {
if ((x - centerX) * (x - centerX) + (y - centerY) * (y - centerY) <= radius * radius) {
pixels.setPixelColor(y * 16 + x, color);
}
}
}
pixels.show();
}
uint32_t randomColor() {
return pixels.Color(random(256), random(256), random(256));
}