// https://forum.arduino.cc/t/help-with-hardware-choice-game-design-early-stages/1284929/
#include <FastLED.h> // http://fastled.io/docs/files.html
#define ROWS 5 // matrix rows
#define COLS 5 // matrix columns
#define NUMPIX (ROWS * COLS) // the full matrix
#define PIXPIN 5 // Arduino data/digital pin
#define MAXBRIGHT 255 // pixels brightness, 0 - 255
CRGB led[NUMPIX]; // create an object named "led" to control [NUMPIX] using FastLED (CRGB)
byte buttonPin = 2;
unsigned long timer, timeout = 50;
bool currentButtonState, lastButtonRead;
void setup() {
Serial.begin(9600); // debugging - not needed
randomSeed(analogRead(A0)); // for more random randomness
pinMode(buttonPin, INPUT_PULLUP);
FastLED.addLeds<WS2812B, PIXPIN, GRB>(led, NUMPIX);
FastLED.setBrightness(MAXBRIGHT); // Adjust the brightness value as needed
FastLED.clear(); // clear pixel buffer
FastLED.show(); // display cleared buffer
}
void loop() {
readButton();
}
void readButton() {
bool currentButtonRead = digitalRead(buttonPin); // read button pin
if (currentButtonRead != lastButtonRead) { // if button pin reading changes...
timer = millis(); // ...start a timer
lastButtonRead = currentButtonRead; // ... and store current state
}
if ((millis() - timer) > timeout) { // if button read change was longer than debounceTimeout
if (currentButtonState == HIGH && lastButtonRead == LOW) { // ... and State NOT pressed while Button PRESSED
russproject();
}
currentButtonState = currentButtonRead; // change the state
}
}
void russproject() {
FastLED.clear();
FastLED.show();
led[random(NUMPIX)] = CRGB::White;
FastLED.show();
}
//**********************************************************************
//
//**********************************************************************
void blinkPanel() {
// byte r = random(256), g = random(256), b = random(256);
byte r = random(2) * 255, g = random(2) * 255, b = random(2) * 255;
for (int i = 0; i < NUMPIX; i++) {
led[i] = CRGB(r, g, b);
}
FastLED.show();
delay(250);
FastLED.clear();
FastLED.show();
delay(250);
}
void corners() {
// row * cols + col
led[0 * COLS + 0] = CRGB(255, 000, 000); // top, left
led[0 * COLS + 6] = CRGB(000, 000, 255); // top, right
led[3 * COLS + 0] = CRGB(255, 255, 000); // bottom, left
led[3 * COLS + 6] = CRGB(000, 255, 000); // bottom, right
FastLED.show();
}
void randomColor() { // random location with random PRIMARY (RGB) or SECONDARY (CMY) color
led[random(ROWS * COLS)] = CRGB(random(2) * 255, random(2) * 255, random(2) * 255);
FastLED.show(); // random pixel in random color
delay(10);
}
nano:12
nano:11
nano:10
nano:9
nano:8
nano:7
nano:6
nano:5
nano:4
nano:3
nano:2
nano:GND.2
nano:RESET.2
nano:0
nano:1
nano:13
nano:3.3V
nano:AREF
nano:A0
nano:A1
nano:A2
nano:A3
nano:A4
nano:A5
nano:A6
nano:A7
nano:5V
nano:RESET
nano:GND.1
nano:VIN
nano:12.2
nano:5V.2
nano:13.2
nano:11.2
nano:RESET.3
nano:GND.3
ring1:GND
ring1:VCC
ring1:DIN
ring1:DOUT
btn1:1.l
btn1:2.l
btn1:1.r
btn1:2.r
vcc1:VCC
gnd1:GND