For short code, it isn't necessay to use pastebin, just use the code tags here.
void loop () {
if(digitalRead (afbryder == 0)) {
//does nothing
} //ends if
else if (digitalRead (afbryder == 1)) {
digitalWrite(SPKR, HIGH); // Turns on speaker
delay(1000); // Turns on sound for one sec.
digitalWrite(SPKR, LOW); // Turns off speaker
delay(100); // Waits 100 mili seconds before turning speaker back on
}
} //ends loop
"digitalRead" can only return zero or one, if it returns one, then it isn't necessary to test for it returning zero, a simple else will suffice.
Is the speaker really just that?
They don't really like DC.
void loop () {
if(digitalRead (afbryder == 1)) {
for (int i = 0; i < 30000; ++i) {
digitalWrite(SPKR, HIGH); // Turns on speaker
delayMicroseconds(500);
digitalWrite(SPKR, LOW); // Turns off speaker
delayMicroseconds(500);
}
}
} //ends loop
Edit: Oops, missed this biggy!
if(digitalRead (afbryder == 0))
You need to be careful where you put your brackets!