Hi. Im working on my first project.... I got some small problems figuring out what digital read means?
I have this text to information to follow:
"""""We want to play a sound each time a button is pressed. We will use a function called check_switches() that goes through the 6 buttons (digital 14 through 20) to see if they have been pressed. If so, we play SOUND1.WAV (for example) completely through. The function that we call here that does the playing is called playcomplete() and we pass the name of the Wave file in quotes just like you see here."""""
I have a hard time making it play when i press a button and to figure out if i press the right button... Im not sure i know what above means ""digital 14 through 20"".
I know the program works when i put some specific number in between 1-6. So its for sure something about pressing the right button. Can you help me on figuring out how to play SOUND1.WAV? Where should i press? In serial monitor or at the board?
Here is the board: http://arduino.cc/en/uploads/Main/arduino-uno-schematic.pdf
byte check_switches()
{
static byte previous[6];
static long time[6];
byte reading;
byte pressed;
byte index;
pressed = 0;
for (byte index = 0; index < 6; ++index) {
reading = digitalRead(14 + index);
if (reading == LOW && previous[index] == HIGH && millis() - time[index] > DEBOUNCE)
{
// switch pressed
time[index] = millis();
pressed = index + 1;
break;
}
previous[index] = reading;
}
// return switch number (1 - 6)
return (pressed);
}