/********* Pleasedontcode.com **********

	Pleasedontcode thanks you for automatic code generation! Enjoy your code!

	- Terms and Conditions:
	You have a non-exclusive, revocable, worldwide, royalty-free license
	for personal and commercial use. Attribution is optional; modifications
	are allowed, but you're responsible for code maintenance. We're not
	liable for any loss or damage. For full terms,
	please visit pleasedontcode.com/termsandconditions.

	- Project: "Random Color"
	- Source Code NOT compiled for: Arduino Uno
	- Source Code created on: 2024-09-02 14:52:43

********* Pleasedontcode.com **********/

/****** SYSTEM REQUIREMENTS *****/
/****** SYSTEM REQUIREMENT 1 *****/
	/* fix the code. */
/****** END SYSTEM REQUIREMENTS *****/

/****** DEFINITION OF LIBRARIES *****/
#include <Adafruit_NeoPixel.h> // Added library for NeoPixel

/****** FUNCTION PROTOTYPES *****/
void setup(void);
void loop(void);
void rndRed(); // Function prototype for rndRed
void rndBlue(); // Function prototype for rndBlue
void rndGreen(); // Function prototype for rndGreen
void rndPurple(); // Function prototype for rndPurple

#define PIN        6
#define NUMPIXELS 15
Adafruit_NeoPixel pixels(NUMPIXELS, PIN, NEO_GRBW + NEO_KHZ800);

// this constant won't change:
const int  btnRed = 2;  // the pin that the pushbutton is attached to
const int  btnBlue = 3;  // the pin that the pushbutton is attached to
const int  btnGreen = 4;  // the pin that the pushbutton is attached to
const int  btnPurple = 5;  // the pin that the pushbutton is attached to

void setup(void)
{
    randomSeed(analogRead(A0)); // This line is compatible as it initializes random seed
    // put your setup code here, to run once:
    pinMode(btnRed, INPUT);
    pinMode(btnBlue, INPUT);
    pinMode(btnGreen, INPUT);
    pinMode(btnPurple, INPUT);

    // initialize the LED as an output:
    // initialize serial communication:
    Serial.begin(9600);
    pixels.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
    pixels.clear(); // Set all pixel colors to 'off'
    pixels.show();
    delay(1000);
}

void loop(void)
{
    // put your main code here, to run repeatedly:
    if (digitalRead(btnRed) == HIGH) {
        rndRed();
        delay(100);
    }

    if (digitalRead(btnBlue) == HIGH) {
        rndBlue();
        delay(100);
    }

    if (digitalRead(btnGreen) == HIGH) {
        rndGreen();
        delay(100);
    }

    if (digitalRead(btnPurple) == HIGH) {
        rndPurple();
        delay(100);
    }
}

void rndRed() {
    int led = random(0, NUMPIXELS); // Fixed range to use NUMPIXELS constant
    pixels.setPixelColor(led, pixels.Color(255, 0, 0, 0)); // Set the selected pixel to red
    pixels.show();   // Send the updated pixel colors to the hardware.
    delay(500);
}

void rndBlue() {
    int led = random(0, NUMPIXELS); // Fixed range to use NUMPIXELS constant
    pixels.setPixelColor(led, pixels.Color(0, 0, 255, 0)); // Set the selected pixel to blue
    pixels.show();   // Send the updated pixel colors to the hardware.
    delay(500);
}

void rndGreen() {
    int led = random(0, NUMPIXELS); // Fixed range to use NUMPIXELS constant
    pixels.setPixelColor(led, pixels.Color(0, 255, 0, 0)); // Set the selected pixel to green
    pixels.show();   // Send the updated pixel colors to the hardware.
    delay(500);
}

void rndPurple() {
    int led = random(0, NUMPIXELS); // Fixed range to use NUMPIXELS constant
    pixels.setPixelColor(led, pixels.Color(171, 0, 255, 0)); // Set the selected pixel to purple
    pixels.show();   // Send the updated pixel colors to the hardware.
    delay(500);
}

/* END CODE */