#include <Wire.h>
//#include <MPU6050.h>
#include <LedControl.h>
//#define MPU6050_ADDRESS 0x68 // Default MPU6050 address
#define Matrix_A 0
#define Matrix_B 1
int PIN_CS = 6;
int PIN_CLK = 4;
int PIN_DIN = 5;
#define Matrix_Height 8
#define Matrix_Width 8
int buttonPin=7;
//MPU6050 mpu;
void animation1(int);
unsigned long delayTime=200;
LedControl lc = LedControl(PIN_DIN, PIN_CLK, PIN_CS, 2);
/*
#define ACC_LOW -25
#define ACC_HIGH 25
#define PIN_X mpu6050.getAngleX()
#define PIN_Y mpu6050.getAngleY()
*/
/*
#define ROTATION_OFFSET 90
#define DEBOUNCE_THRESHOLD 500
#define DELAY_FRAME 100
#define MODE_HOURGLASS 0
#define MODE_SETMINUTES 1
#define MODE_SETHOURS 2
byte delayHours = 0;
byte delayMinutes = 1;
int mode = MODE_HOURGLASS;
int gravity;
int resetCounter = 0;
long getDelayDrop() {
// since we have exactly 60 particles we don't have to multiply by 60 and then divide by the number of particles again :)
return delayMinutes + delayHours * 60;
}
*/
void setup(){
pinMode(buttonPin, INPUT_PULLUP);
lc.shutdown(0,false);
lc.setIntensity(0,8);
lc.clearDisplay(0);
Serial.begin(9600);
Wire.begin();
//mpu.initialize();
}
void loop()
{
// Read gyro data
//int16_t gyroX, gyroY, gyroZ;
//mpu.getRotation(&gyroX, &gyroY, &gyroZ);
// Check if the sensor is flipped
// Adjust this threshold based on your sensor orientation
// Display falling LEDs on matrix1
int buttonState=digitalRead(buttonPin);
lc.clearDisplay(0);
lc.clearDisplay(1);
if(digitalRead(buttonPin)==LOW){
for (int i = 0; i < Matrix_Height; i++) {
lc.setRow(0, i, B11111111); // Turn on all LEDs in the current row
delay(300); // Adjust the falling speed
// Adjust the falling speed
lc.setRow(1, i, B00000000); // Turn on all LEDs in the current row
delay(300);
// Adjust the falling speed
if (i > 0) {
lc.setRow(0, i - 1, B00000000);
delay(300);
}
lc.setRow(1, i, B11111111); // Turn on all LEDs in the current row
delay(300);
}
lc.clearDisplay(0);
lc.clearDisplay(1);
}
if(digitalRead(buttonPin)==LOW){
for (int i = 0; i < Matrix_Height; i++) {
lc.setRow(0, i, B01111110); // Turn on all LEDs in the current row
delay(300); // Adjust the falling speed
lc.setRow(1, i, B00000000); // Turn on all LEDs in the current row
delay(300); // Adjust the falling speed
if (i > 0) {
lc.setRow(0, i - 1, B00000000);
delay(300);
} // Adjust the falling speed
lc.setRow(1, i, B01111110); // Turn on all LEDs in the current row
delay(300); // Adjust the falling speed
}
}
}
/*void animation1(int buttonReading){
if(buttonReading==LOW){
for (int i = 0; i < Matrix_Height; i++) {
lc.setRow(0, i, B11111111); // Turn on all LEDs in the current row
delay(2000); // Adjust the falling speed
lc.setRow(0, i, B11111111); // Turn on all LEDs in the current row
delay(2000); // Adjust the falling speed
delay(2000);
}
}
*/