Hello Arduino Forum!
I've gone in way over my head here, but I thought maybe you guys could show me the next step, if anyone has a second.
The Idea
Use 8 pushbuttons connected to 8 digital ins on the arduino, controlling two max395 piggybacked on one another.
The Schematic
Note that pins 2-9 all have the same switching connection, but there wasn't enough room to put them all on each pin, so only pins 2 and 9 are shown.
The Reason
Each switch toggles one switch in each 395, the same in each, which controls an audio pathway in one 395, and an LED in the second. That one, when one button is pushed, the corresponding LED is lit, showing that pathway is activated.
The Code
Now the part I noob out. The basic idea of this was based on a good fellow named Arnoud on another forum, who used a different voltage divider on each switch, reading the voltage on one pin to determine which button was pushed. He used a 395 for switching and a 4015 for the LED's. I'd like to keep it simple and just use 395.
I have this as the setup:
const int rep1 = 2; //Repeat button 1 to digital pin 2
const int rep2 = 3; //Repeat button 2 to digital pin 3
const int rep3 = 4; //Repeat button 3 to digital pin 4
const int rep4 = 5; //Repeat button 4 to digital pin 5const int reg1 = 6; //Regeneration button 1 to digital pin 6
const int reg2 = 7; //Regeneration button 1 to digital pin 7
const int reg3 = 8; //Regeneration button 1 to digital pin 8
const int reg4 = 9; //Regeneration button 1 to digital pin 9int max_clock = 13; //Output clock for max395
int max_data = 12; //Output data for max395
int max_cs = 11; //Output cs for max395void setup () {
pinMode (rep1, INPUT); //Initialize repeat pins as inputs
pinMode (rep2, INPUT);
pinMode (rep3, INPUT);
pinMode (rep4, INPUT);
pinMode (reg1, INPUT); //Initialize regen pins as inputs
pinMode (reg2, INPUT);
pinMode (reg3, INPUT);
pinMode (reg4, INPUT);
pinMode (max_clock, OUTPUT); //Initialize 13,12,11 as outputs
pinMode (max_data, OUTPUT);
pinMode (max_cs, OUTPUT);
}
Then, I get confused : I have seen code similar to what the predisesor of the idea used, which may or may not have looked something like this
void loop () {
int sum = 0; //Setting max395
if(digitalRead(rep1) == HIGH){
sum += 128;
}
if(digitalRead(rep2) == HIGH){
sum += 64;
}
if(digitalRead(rep3) == HIGH){
sum += 32;
}
if(digitalRead(rep4) == HIGH){
sum += 16;
}if(digitalRead(reg1) == HIGH){
sum += 8;
}
if(digitalRead(reg2) == HIGH){
sum += 4;
}
if(digitalRead(reg3) == HIGH){
sum += 2;
}
if(digitalRead(reg4) == HIGH){
sum += 1;
}return sum;
}
However, I don't quite understand what is going on or if anything like that is close to being correct. I also understand that there may need to be some debounce code somewhere, but I couldn't quite get that into my head either >:(
Does anybody have advice on how to continue this project? Any advice is much appreciated. Thank you!
Ciao,
Die Fenster