I just received my Arduino Uno, and I am trying different sketches. Some are working, some are not. How can I know that the Uno is working properly? The following sketch is not working. I got this from a book. Any insight is welcome.
// arduino_sounds
int sw1pin = 6;
int sw2pin = 7;
int soundPin = 8;
void setup()
{
pinMode(sw1pin, INPUT_PULLUP);
pinMode(sw2pin, INPUT);
pinMode(soundPin, OUTPUT);
}
void loop()
{
if (! digitalRead (sw1pin))
{
tone(soundPin, 100);
}
else if (! digitalRead (sw2pin))
{
tone(soundPin, 300);
}
else
{
noTone(soundPin);
}
}