const byte tasterRot = 6;
const byte tasterGruen = 5;
const byte tasterBlau = 4;
const byte tasterGelb = 3;
const byte ledRot = 9;
const byte ledGruen = 13;
const byte ledBlau = 12;
const byte ledGelb = 10;
const byte piezo = 11;
const unsigned int TONE1 = 1000;
const unsigned int TONE2 = 2000;
void setup() {
pinMode(tasterRot, INPUT_PULLUP);
pinMode(tasterGruen, INPUT_PULLUP);
pinMode(tasterBlau, INPUT_PULLUP);
pinMode(tasterGelb, INPUT_PULLUP);
pinMode(piezo, OUTPUT);
pinMode(ledRot, OUTPUT);
pinMode(ledGruen, OUTPUT);
pinMode(ledBlau, OUTPUT);
pinMode(ledGelb, OUTPUT);
}
void loop() {
digitalWrite(ledRot, !digitalRead(tasterRot));
digitalWrite(ledGruen, !digitalRead(tasterGruen));
digitalWrite(ledBlau, !digitalRead(tasterBlau));
digitalWrite(ledGelb, !digitalRead(tasterGelb));
if( !digitalRead(tasterRot))
{
tone(piezo, TONE1);
}
else if( !digitalRead(tasterGruen) || !digitalRead(tasterBlau) || !digitalRead(tasterGelb) )
{
tone(piezo, TONE2);
}
else
{
noTone(piezo);
}
}