Hey all, totaly new to arduino here and still learning what is all possible and what isnt. Writing programs for this board (UNO i think) has proven to be a challenge.
I am currently working on a project where I need my arduino to send on/off signals to another board (sound fx board from adafruit) and manipulate the pins on a dime. what i mean is that i need 2 switches to control 3 distinct sounds in a fashion i cant seem to figure out.
The sound kit im using isnt polyphonic, meaning it can not play one sound while another is playing. What I am looking to accomplish is pretty strange i think. First, button 1 has to be able to play Sound #1, then delay x amount of seconds and trigger Sound #3 when Button 1 is pressed the first time only (this button is a toggle switch that will remain HIGH that will be spliced into third electronics kit as its power switch). Then I need Button 2 to play Sound 2 when HIGH and go back to sound #3 when it returns to its low state. I would like to incorporate a sound 4 if button 2 is held high for too long (10 seconds or so) but it would still need to go back to sound 3 after that cycle.
am i on the right track with my code here or is there something else entirely different i need to be doing? thanks in advance!
const int button1 = 12;
const int button2 = 13;
const int button3 = 11;
const int sound1 = 9;
const int sound2 = 8;
const int sound3 = 7;
int buttonState = 0;
void setup() {
pinMode(sound1, OUTPUT);
pinMode(button1, INPUT);
pinMode(button2, INPUT);
}
void loop(){
// read the state of the pushbutton value:
buttonState = digitalRead(button1);
buttonState = digitalRead(button2);
if (button1 == HIGH) {
// turn Sound 1 on:
digitalWrite(sound1, HIGH);
}
else {
digitalWrite(sound1, LOW);
if (button2 == HIGH) {
// turn Sound 2 on:
digitalWrite (sound2, HIGH);
}
}
else {
// turns on HUM LOOP effect:
digitalWrite(sound3, HIGH);
}
}