heyo. i'm currently sitting on a little project and so far it seems okay but now i get the error "Error compiling for board Arduino Uno."
idk what i should do, can anybody help me?
Code:
#include <Wire.h>
#include <Conceptinetics.h>
#include <TM1637Display.h>
#include <EEPROM.h>
// Pins for the buttons
const int buttonMinusPin = A0; // Change to analog pin
const int buttonPlusPin = A1; // Change to analog pin
// Pins for the TM1637 Display
const int CLK = 2; // Pin for CLK
const int DIO = 3; // Pin for DIO
// Variables for the buttons
int lastButtonMinusState = HIGH;
int lastButtonPlusState = HIGH;
unsigned long lastDebounceTimeMinus = 0;
unsigned long lastDebounceTimePlus = 0;
unsigned long debounceDelay = 50;
unsigned long buttonPressStartTimeMinus = 0;
unsigned long buttonPressStartTimePlus = 0;
bool isButtonPressedMinus = false;
bool isButtonPressedPlus = false;
// DMX Slave object
#define DMX_SLAVE_CHANNELS 3 // Number of DMX channels
#define RXEN_PIN 2 // RXEN Pin (receive enable)
DMX_Slave dmx_slave(DMX_SLAVE_CHANNELS, RXEN_PIN); // Create DMX Slave object
// TM1637 Display object
TM1637Display display(CLK, DIO);
// EEPROM memory address for DMX address
const int eepromAddress = 0;
void setup() {
Wire.begin(); // Start I2C
Serial.begin(9600); // Start serial communication
pinMode(buttonMinusPin, INPUT_PULLUP);
pinMode(buttonPlusPin, INPUT_PULLUP);
// Initialize DMX Slave
dmx_slave.enable(); // Enable DMX Slave
dmx_slave.setStartAddress(1); // Set start address for DMX
// Initialize TM1637 Display
display.setBrightness(0x0f); // Maximum brightness
}
void loop() {
handleButtonPresses();
// Receive DMX data
dmx_slave.enable();
int dmxAddress = 1; // Change to the corresponding channel number
int dmxValue = dmx_slave.getChannelValue(dmxAddress);
display.showNumberDec(dmxValue, true);
// Map DMX values to PWM values
int pwmValue = map(dmxValue, 0, 255, 0, 1023);
// Send PWM values I2C
sendPWMValues(pwmValue, pwmValue, pwmValue);
// Debug output
Serial.print("DMX Channel ");
Serial.print(dmxAddress);
Serial.print(": ");
Serial.println(dmxValue);
// Delay for control of update speed
delay(10);
}
void handleButtonPresses() {
int buttonMinusState = analogRead(buttonMinusPin) < 512 ? LOW : HIGH;
int buttonPlusState = analogRead(buttonPlusPin) < 512 ? LOW : HIGH;
unsigned long currentTime = millis();
// Minus button
if (buttonMinusState == LOW && lastButtonMinusState == HIGH) {
lastDebounceTimeMinus = currentTime;
buttonPressStartTimeMinus = currentTime;
isButtonPressedMinus = true;
} else if (buttonMinusState == HIGH && lastButtonMinusState == LOW) {
if (isButtonPressedMinus && currentTime - buttonPressStartTimeMinus >= debounceDelay) {
int currentAddress = dmx_slave.getStartAddress();
dmx_slave.setStartAddress(max(1, currentAddress - 1));
EEPROM.write(eepromAddress, dmx_slave.getStartAddress());
isButtonPressedMinus = false;
}
} else if (buttonMinusState == LOW && isButtonPressedMinus && currentTime - buttonPressStartTimeMinus >= 1000) {
if (currentTime - buttonPressStartTimeMinus >= 100) {
int currentAddress = dmx_slave.getStartAddress();
dmx_slave.setStartAddress(max(1, currentAddress - 1));
EEPROM.write(eepromAddress, dmx_slave.getStartAddress());
buttonPressStartTimeMinus = currentTime;
}
}
lastButtonMinusState = buttonMinusState;
// Plus button
if (buttonPlusState == LOW && lastButtonPlusState == HIGH) {
lastDebounceTimePlus = currentTime;
buttonPressStartTimePlus = currentTime;
isButtonPressedPlus = true;
} else if (buttonPlusState == HIGH && lastButtonPlusState == LOW) {
if (isButtonPressedPlus && currentTime - buttonPressStartTimePlus >= debounceDelay) {
int currentAddress = dmx_slave.getStartAddress();
dmx_slave.setStartAddress(min(512 - DMX_SLAVE_CHANNELS + 1, currentAddress + 1));
EEPROM.write(eepromAddress, dmx_slave.getStartAddress());
isButtonPressedPlus = false;
}
} else if (buttonPlusState == LOW && isButtonPressedPlus && currentTime - buttonPressStartTimePlus >= 1000) {
if (currentTime - buttonPressStartTimePlus >= 100) {
int currentAddress = dmx_slave.getStartAddress();
dmx_slave.setStartAddress(min(512 - DMX_SLAVE_CHANNELS + 1, currentAddress + 1));
EEPROM.write(eepromAddress, dmx_slave.getStartAddress());
buttonPressStartTimePlus = currentTime;
}
}
lastButtonPlusState = buttonPlusState;
}
void sendPWMValues(int pwmValue1, int pwmValue2, int pwmValue3) {
Wire.beginTransmission(0x01);
Wire.write(pwmValue1); // Send PWM value for pin 1
Wire.write(pwmValue2); // Send PWM value for pin 2
Wire.write(pwmValue3); // Send PWM value for pin 3
Wire.endTransmission();
Wire.beginTransmission(0x02);
Wire.write(pwmValue1); // Send PWM value for pin 1
Wire.write(pwmValue2); // Send PWM value for pin 2
Wire.write(pwmValue3); // Send PWM value for pin 3
Wire.endTransmission();
}