Hi, I have a working Deej project (something that adjusts the sound levels in windows) and want to add a digital clock to try and make an all-in-one desk device. I can get both parts working correctly, but when I try and combine the two, I get an "lvalue required as left operand of assignment" error on line 121, LED_ON=3;. I have traced the issue to #include "Adafruit_LEDBackpack.h" where the code will compile if I comment it out.
Any help in diagnosing will be helpful.
//Deej Setup
const int NUM_SLIDERS = 5;
const int analogInputs[NUM_SLIDERS] = {A0, A1, A2, A3, A6};
const int NUM_BUTTONS = 6;
const int buttonInputs[NUM_BUTTONS] = {6,5,4};
int analogSliderValues[NUM_SLIDERS];
int buttonValues[NUM_BUTTONS];
const int BUTTON_1 = 4;
const int BUTTON_2 = 5;
const int BUTTON_3 = 6;
const int LED_1 = 7;
const int LED_2 = 8;
const int LED_3 = 9;
int BUTTONstate_1 = 0;
int BUTTONstate_2 = 0;
int BUTTONstate_3 = 0;
int LED_ON = 0;
//Add Clock Stuf
#include <Wire.h>
#include <Adafruit_GFX.h>
#include "Adafruit_LEDBackpack.h"
#include "RTClib.h"
void setup() {
for (int i = 0; i < NUM_SLIDERS; i++) {
pinMode(analogInputs[i], INPUT);
}
for (int i = 0; i < NUM_BUTTONS; i++) {
pinMode(buttonInputs[i], INPUT_PULLUP);
}
pinMode(BUTTON_1, INPUT);
pinMode(BUTTON_2, INPUT);
pinMode(BUTTON_3, INPUT);
pinMode(LED_1, OUTPUT);
pinMode(LED_2, OUTPUT);
pinMode(LED_3, OUTPUT);
Serial.begin(9600);
}
void loop() {
updateSliderValues();
sendSliderValues(); // Actually send data (all the time)
// printSliderValues(); // For debug
button_LED();
delay(10);
}
void updateSliderValues() {
for (int i = 0; i < NUM_SLIDERS; i++) {
analogSliderValues[i] = analogRead(analogInputs[i]);
}
for (int i = 0; i < NUM_BUTTONS; i++) {
buttonValues[i] = digitalRead(buttonInputs[i]);
}
}
void sendSliderValues() {
String builtString = String("");
for (int i = 0; i < NUM_SLIDERS; i++) {
builtString += "s";
builtString += String((int)analogSliderValues[i]);
if (i < NUM_SLIDERS - 1) {
builtString += String("|");
}
}
if(NUM_BUTTONS > 0){
builtString += String("|");
}
for (int i = 0; i < NUM_BUTTONS; i++) {
builtString += "b";
builtString += String((int)buttonValues[i]);
if (i < NUM_BUTTONS - 1) {
builtString += String("|");
}
}
Serial.println(builtString);
}
void printSliderValues() {
for (int i = 0; i < NUM_SLIDERS; i++) {
String printedString = String("Slider #") + String(i + 1) + String(": ") + String(analogSliderValues[i]) + String(" mV");
Serial.write(printedString.c_str());
if (i < NUM_SLIDERS - 1) {
Serial.write(" | ");
} else {
Serial.write("\n");
}
}
}
void button_LED (){
BUTTONstate_1 = digitalRead(BUTTON_1);
if (BUTTONstate_1 == HIGH)
{
LED_ON=1;
}
BUTTONstate_2 = digitalRead(BUTTON_2);
if (BUTTONstate_2 == HIGH)
{
LED_ON=2;
}
BUTTONstate_3 = digitalRead(BUTTON_3);
if (BUTTONstate_3 == HIGH)
{
LED_ON=3;
}
if (LED_ON==1)
{
digitalWrite(LED_1, HIGH);
}
else
{
digitalWrite(LED_1, LOW);
}
if (LED_ON==2)
{
digitalWrite(LED_2, HIGH);
}
else
{
digitalWrite(LED_2, LOW);
}
if (LED_ON==3)
{
digitalWrite(LED_3, HIGH);
}
else
{
digitalWrite(LED_3, LOW);
}
Serial.println (LED_ON);
}