/* Written by: Zuzanna Last update: 1st March 2024. This file contains code for Rewise GFG Steelworks Retrofit - Support Office Sector. Lookout for line with star symbol or // - these are comments that are here to guide you through the code. -------------------------- These are wiring instructions (sensor -> arduino) -------------------------- Display - Arduino Nano GND -> GND 5V -> 5V DIN -> Pin 11 CS -> Pin 10 CLK -> Pin 13 -------------------------- Button - Arduino Nano + -> Pin 8 - -> GND */ //------------------ LIBRARIES ------------------ #include "LedControl.h" #define DIN_PIN 11 #define CS_PIN 10 #define CLK_PIN 13 #define BUTTON_PIN 8 //------------------ CREATING INSTANCES ------------------ LedControl lc = LedControl(DIN_PIN, CLK_PIN, CS_PIN, 1); //------------------ VARIABLES ------------------ int buttonState = 0; int lastButtonState = 0; int currentLED = 0; //------------------------ VOID SETUP()------------------------ void setup() { lc.shutdown(0, false); // Wake up MAX7219 lc.setIntensity(0, 3); // Set brightness (0 to 15) // Display all LEDs for (int i = 0; i < 8; i++) { for (int j = 0; j < 8; j++) { lc.setLed(0, i, j, true); delay(70); // Adjust delay if needed } } pinMode(BUTTON_PIN, INPUT_PULLUP); } //------------------------ VOID LOOP()------------------------ void loop() { buttonState = digitalRead(BUTTON_PIN); if (buttonState == LOW && lastButtonState == HIGH) { // Button pressed lc.setLed(0, currentLED % 8, currentLED / 8, false); currentLED++; if (currentLED == 64) { lc.clearDisplay(0); // Turn OFF all LEDs, restart currentLED = 0; } } lastButtonState = buttonState; }